有趣的数

作者: 不连续小姐 | 来源:发表于2019-01-12 01:02 被阅读1次

Python Day 3: Finding Fun Numbers

数学界有个关于 1729的故事, the Ramanujan Number.
一天 Hardy 去医院看 Ramanujan, 他说来的路上搭了一辆牌照很没有意思的士, 1729. Ramanujan 说: 不,这个数非常有意思; it is the smallest number expressible as the sum of two cubes in two different ways. (这是一个可以用两个立方和表达的最小数)

1729 = 13 + 123 = 93 + 103

我们今天用 python 来找一下有趣的数, the sum of divisors' square number(因子平方和完全平方数), and perfect number (完美数).

[caption id="attachment_1416" align="alignnone" width="1024"] image

GraphicMama-team / Pixabay[/caption]

Perfect Number: a perfect number is a positive integer that is equal to the sum of its proper positive divisors (除自己以外的因子和相加等于自己)

Example: the proper divisor of 6 is 1,2,3 and 6 = 1+2+3.

Python code:

#we want to find all the perfect number within 1000.
sieve= [1]*(1000+1)

n = 2
while n <= 1000:
    # check n
    if sieve[n] == n:
        print(n, "is a perfect number")
    # add n to all k * n where k > 1
    kn = 2 * n
    while kn <= 1000:
        sieve[kn] += n
        kn += n
    n += 1

Result:

6 is a perfect number
28 is a perfect number
496 is a perfect number

We can see 6,28 and 496 are perfect numbers.

[caption id="attachment_1415" align="alignnone" width="1024"] image

InspiredImages / Pixabay[/caption]

The sum of divisors' square number

Suppose we want to find some number such that the Sum of the squares of the number's divisors is a perfect square number

Example:

The divisors of 42 are 1,2,3,6,7,14,21,42

the square of divisors are 1,4,9,36,49, 196, 441, 1764

Sum of the square of divisors are 1+4+9+ 36+49+196+441+1764=2500

2500=500 * 500 is a perfect square

Python Code:

def list_squared(m,n):
    list=[]
    for i in range(m,n+1):
        sum=0
        s_list=[]
        for j in range(1,int(i**0.5)+1):
            if i%j==0:
                div=i/j
                sum+=j**2
                if j!=div:
                    sum+=div**2
        sqt=sum**0.5
        if int(sqt)==sqt:
            s_list=[i,sum]
            list.append(s_list)
    return list

list_squared(42,250)

Output:

[[42, 2500.0], [246, 84100.0]]

We can see 42, and 246 satisfy the conditions in the range (42,250)

我喜欢数论,因为它赋予了每一个数字特殊的意义 :) , 最近两年,朋友和我都会对已经过去的和未来要来得年纪有一些敏感和伤感. 但我看这些数的时候,每一个都那么特别,都那么美:

27, the Cube age 立方年,
28, the Perfect age 完美年,
29, a Gaussian age 高斯年,
30, a smallest 2,3,5, divisor age 因子年,
31, a PRIME age 最好年 ,
32, a Binary age 二进制年!!!

I like my number theory classmate JOHNES said:

Appreciated every little things in life, like Tuesdays, it only comes once a week!
要感恩小事情哦, 像星期二,一周才一次 :)

Happy Studying! 🐼

相关文章

  • 有趣的数

    Python Day 3: Finding Fun Numbers 数学界有个关于 1729的故事, the Ra...

  • 有趣的完美数

    在奥妙的数学王国中,有着一群有趣的小精灵——那就是数字。 数字分为许多种,有单数,有双数,有质数,有合数……在...

  • 有趣的数独

    今天我做了数独,很有意思呢,而且规律不一样 你发现规律了吗?这个不是一般规律的。我还把它画下来了呢,你们也可以来看...

  • 算法

    阿姆斯特朗数 有趣的电影

  • 有趣的数串模型

    孩子对等差数列求个数的公式中为什么要除公差不是很理解。 继鸡兔同笼模型之后,我们今天就来了一场士兵集合演练模型,去...

  • 121丨副业发展千万条,首选趣步是王道🎉

    往有趣人、趣事、趣头条 我有趣步 ,不走冤枉路 走路有受益 ,还看今朝! 2.26总步数 3565,糖果数1.35...

  • 201312-4 有趣的数

    问题描述: 我们把一个数称为有趣的,当且仅当:它的数字只包含0, 1, 2, 3,且这四个数字都出现过至少一次。所...

  • 数独的世界真有趣

    今日数独的书到了,懒懒玩了一整天的数独。 九个数字,各种神奇的排列组合,既做到每个数都出现又做到不重复,每个逻辑都...

  • 数对中的有趣思考

    最近在准备公开课,恰好看到贲友林《学生视野中的小学数学问题研究》中的一个问题:为什么数对是先写列而不是先写行?觉得...

  • 2020-01-10 北京记事

    发现自己活得忘记了年龄,不知不觉到了一个有趣的年纪,在年份是跌数,年龄也是跌数的有趣一年,给自己确立几个目标,顺便...

网友评论

    本文标题:有趣的数

    本文链接:https://www.haomeiwen.com/subject/kdhqdqtx.html