Find all possible pairs (m,n) of prime numbers that satisfy this equation:
2m = 2n-2 + n!
Prove that there are no other valid pair that conform to the given conditions.
*** Computer program assisted solutions are welcome, but a semi-analytic (hand calculator and p&p solution) is preferred.
I found two solutions:
(m,n) = {(3,3), (7,5)}
-------------------
def fact(n):
if n == 1 or n == 0:
return 1
ans = 1
for i in range(n):
ans *= (i+1)
return ans
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
primes = [i for i in range(1001) if isprime(i)]
for m in primes:
for n in primes:
if 2**m == 2**(n-2) + fact(n):
print(m,n)
|
Posted by Larry
on 2023-08-03 11:41:22 |