You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

寻找满足特定整除条件的正整数n,p,q的技术咨询(m=2场景)

寻找满足特定整除条件的正整数n,p,q的技术咨询(m=2场景)

我最近碰到个编程相关的数学问题,老师要求找三个正整数n、p、q(给定m=2),得满足以下两个整除条件:

  • p和q都能整除2n² - 1
  • 2n能整除p - q

我写了一段Python代码来查找,把n的迭代上限设到了1000000,但跑完之后没找到任何符合条件的数。现在我有点拿不准,到底是这类n根本不存在,还是我的代码逻辑有问题?

附上我写的代码:

from sympy import isprime

def find_integers():
    solutions = []
    max_n = 10**6  # Upper limit for n
    for n in range(1, max_n + 1):
        if not isprime(2 * n ** 2 - 1):
            for p in range(1, 2 * n ** 2 - 1, 2):
                for q in range(1, 2 * n ** 2 - 1, 2):
                    if (2 * n ** 2 - 1) % p == 0 and (2 * n ** 2 - 1) % q == 0 and (p - q) % (2 * n) == 0 and p != q:
                        solutions.append((n, p, q))
        if n % 100 == 0:  # Print progress every 100 iterations
            print(f"Progress: n = {n}")
    return solutions

# Find the solutions
solutions = find_integers()

# Display the results
if solutions:
    print("Solutions:")
    for i, (n, p, q) in enumerate(solutions):
        print(f"Solution {i + 1}: n = {n}, p = {p}, q = {q}")
else:
    print("No solutions found.")

另外补充个消息,这个问题现在已经完全解决了:

  • m=2的情况由Denis Shatrov完成证明
  • m>1的情况由GH from MO完成证明

备注:内容来源于stack exchange,提问作者No Name

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.20 08:23:11