• Amber timed how long she took to solve a monthly mathematical contest. She writes down the elapsed time in DD:HH:MM:SS format and also in seconds.
• For example, if she spent 1,000,000 seconds, she would write down 11:13:46:40 and 1,000,000.
Amber shares her numbers with Bryce. Bryce subtracts her two numbers (higher one minus the lower one), ignoring punctuations. In this case Bryce would obtain:
• 11134640 - 1000000 = 10134640
Determine the maximum value of the positive integer that must always divide his result.
Explain your answer with valid arguments.
D = 86400 (# seconds in a day)
H = 3600
M = 60
S = 1
If there are s seconds, Amber's number is just s.
Using the format,
Bryce's number is 1000000*d + 10000*h + 100*m + s
Amber's number is 86400*d + 3600*h + 60*m + s
The difference is: 913600*d + 6400*h + 40*m
Since 40 divides the other coefficients, answer =
40A program to confirm started with random integer values for d,h,m,s, then calculated the difference, computed the factors of the difference then used the intersection of sets to find the factors in common, which were:
[2, 4, 5, 8, 10, 20, 40] (output of program below)
-----
import random
def factors(n):
""" for integer n, return a list of all the factors including or not 1 and n """
ans = [1,n]
ans = []
for i in range(2,2+int(n**.5)):
if n%i == 0:
ans.append(i)
ans.append(int(n/i))
return sorted(ans)
def seconds(d,h,m,s):
return 86400*d + 3600*h + 60*m + s
def no_colons(d,h,m,s):
return 1000000*d + 10000*h + 100*m + s
def diff(d,h,m,s):
return 913600*d + 6400*h + 40*m
for i in range(50):
if i == 0:
incommon = set(factors(diff(25,15,33,10)))
d = random.randint(0,30)
h = random.randint(0,23)
m = random.randint(0,59)
s = random.randint(0,59)
difference = diff(d,h,m,s)
totalSeconds = seconds(d,h,m,s)
if totalSeconds < 1000000:
continue
myfactors = set(factors(diff(d,h,m,s)))
incommon = incommon.intersection(myfactors)
print(sorted(list(incommon)))
|
Posted by Larry
on 2023-04-25 06:55:54 |