Determine all possible triplets (p, q, n) of nonnegative integers that satisfy this equation:
2p + 2q = n!
Provide valid argument for your answer.
*** Adapted from a problem which appeared at the Harvard/MIT math Olympiad.
A program finds only three such triplets for (p, q, n), if p <= q:
(0, 0, 2)
(1, 2, 3)
(3, 4, 4)
p and q can be swapped in the last two bringing the total to 5.
Completeness argument:
There can be no value of n greater than 6.
Every factorial greater than or equal to 7! is divisible by 7. But powers of 2 can only be {1,2,4} mod 7. So there is no way to add two powers of 2 to get 0 mod 7. So the largest n! can be is 6! = 720. Since 2^10 > 720, there is no need to test any p or q > 10
"""
def fac(n):
""" Factorial """
if n == 1 or n == 0:
return 1
else:
return n*fac(n-1)
big = 100
factorials = [fac(i) for i in range(0,big)]
for p in range(11):
for q in range(p,11):
if (2**p + 2**q)%7 == 0:
print(p,q)
if 2**p + 2**q in factorials:
print('({}, {}, {})'.format (p,q, factorials.index(2**p + 2**q)) )
|
Posted by Larry
on 2023-02-27 16:02:12 |