如何在列表中划分特定数字?

问题描述 投票:0回答:1

梅森素数遵循此公式2 ^ n-1。我为不会产生梅森素数的数字创建了一种新型的因式分解方法。这是非常抽象的。其前提是,如果使用模块化数学方法应用了特定数字,而新数字变为(零),则它不是梅森素数。我在线上向《数论杂志》提交了一篇论文,但遭到该杂志的拒绝。我已经附上了它,如果您想查看一下,我仍然觉得我的方法很有希望,但我不是编码专家。 This is a pdf I sent to the Journal of Number Theory我的问题是在我的新代码中,我不知道如何在清单。该列表枚举还可以,但是我想从253中减去z = 11,等于242,然后再将其乘以121,但是当我创建从1-254的范围时,我似乎无法执行此数学运算。我对此感兴趣的原因是253 // 11 = 23,这是2 ^ 11-1的倍数。我从比率页面得到了这个想法。

类型1:11,第二个数字是22,只需加1及其23。

签出https://goodcalculators.com/ratio-calculator/

该公式将定位范围内的任何数字,而我正在寻找的是零。

在这里学习帮助的程序员是我的程序:

    while True:
        x = int(input("Start Range: "))
        i = int(input("End Range: "))
        z = int(input("square of  primes multiplied by a number plus z which does not make a 
    mersenne prime, this finds its factor of z: "))
        fact = [(i + 1, x) for i, x in enumerate(range(x, i))]


    """My subtraction and mod is not doing what it is suppose to in the list, because I'm a 
    lame 
    programmer"""
    print([((int(i)-z) % (z*z)) if isinstance(i, str) else i for i in fact])
python math numbers theory
1个回答
0
投票

[也许您正在尝试的是,不需要int调用,因为值从一开始就是integers。另外,请勿将同一变量i用于不同目的:

calculations = [
    (fact_tuple[0] - z) % (z*z) for fact_tuple in fact
]
print(calculations) # with x = 1, i = 254, z = 11
>>> [111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 0]

© www.soinside.com 2019 - 2024. All rights reserved.