Non-abundant Sumsproblem 23
A perfect number is a number for which the sum of it proper divisors is exactly equal to the number. For example, the sum of the proper divisors of would be 1 + 2 + 4 + 7 + + =, which means. is a perfect numbe R.
A number is n called deficient if the sum of its proper divisors are less than and n it's called abundant if this Sum exceeds n .
As is the smallest abundant number, 1 + 2 + 3 + 4 + 6 = +, the smallest number so can be written as the sum of Bundant numbers is 24. By mathematical analysis, it can be shown, so all integers greater than 28123 can be written as the sum of the of the abundant n Umbers. However, this upper limit cannot being reduced any further by analysis even though it's known that the greatest number that Cannot be expressed as the sum of of the abundant numbers are less than this limit.
Find the sum of the positive integers which cannot be written as the sum of the abundant numbers.
Go to the thread for problem the forum.
Python code:
Import Math
Sqrt=math.sqrt
def func1 (x):
M=SQRT (x)
If M-int (m) ==0:
K=1+int (M)
For I in range (2,int (m)):
If x%i==0:
K+=i+int (x/i)
Return K
Else
K=1
For I in range (2,int (m+1)):
If x%i==0:
K+=i+int (x/i)
Return K
dict={}
A=[]
For I in Range (12,28123):
If Func1 (i) >i:
A.append (i)
Dict[i]=1
def func2 (x):
I=0
K=len (a)
While A[i]<x and i<k:
If Dict.get (X-a[i]) ==1:
Return 1
I+=1
return 0
Result=0
For I in Range (1,28123):
If Func2 (i) ==0:
Result+=i
Print (Result)
Time:2s
------------------Wish you good health and good luck
Huadian North Wind Blows
Key Laboratory of cognitive computing and application, School of Computer Science and technology, Tianjin University
No. 92nd, Wei Jin Road, Tianjin
Zip: 300072
Email: [email protected]q.com
Euler program (python) problem 23