If N is a nonnegative integer, the triangular number T(N)=1+2+3+...+N is given by N(N+1)/2.
Find a prime P such that the sum of the proper divisors of T(P) is a cube.
I also find only 2 and 53.
If N is included, and use the sum of all divisors, rather than proper divisors excluding N, then I found no solutions.
-----
Program output:
2 3 1 1
53 1431 729 9
--------------------
def isprime(n):
'''check if integer n is a prime'''
n = abs(int(n))
if n < 2:
return False
if n == 2:
return True
if not n & 1:
return False
for x in range(3, int(n**0.5)+1, 2):
if n % x == 0:
return False
return True
def tri(n):
""" input an integer, returns the n-th triangular number. """
return int(n*(n+1)/2)
def iscube(n):
""" Input an integer, Returns True iff it is a perfect cube. """
if round(n**(1/3))**3 == n:
return True
else:
return False
def proper_divisors(n):
""" input integer, output list of lists of divisors of n
including 1 but not including n """
divisors = [1]
for i in range(2,int(n/2)+2):
if (n/i)%1 != 0:
continue
divisors.append(i)
return divisors
big = 1000
primes = [i for i in range(1,big) if isprime(i)]
for n in primes:
if not iscube(sum(proper_divisors(tri(n)))):
continue
print(n, tri(n), sum(proper_divisors(tri(n))), round((sum(proper_divisors(tri(n))))**(1/3)))
|
Posted by Larry
on 2023-12-29 10:47:48 |