If the tetradecimal (base 14) number c#95d# is divisible by the tetradecimal number 76, then determine the missing digits.
Note: Each hash represents a digit, whether same or different.
Note that the 6 digit base 14 number can be written Cx95Dy
(p&p below)
A short program finds only [7, 6]
C795D6 base 14 is 6748664 base 10
def base2base(n,a,b):
""" input n which is a string of the number to be changed
'a' is an integer representing the current base
to be changed to base b
"""
def dec2base(i,base):
""" INPUT integer in base 10, return string
of Base base equivalent. """
convertString = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
if i < base:
return convertString[i]
else:
return dec2base(i//base,base) + convertString[i%base]
if a == 10:
return dec2base(int(n),b)
if b == 10:
return int(str(n),a)
elif b != 10:
return base2base(int(str(n),a),10,b)
xyvalues = []
for x in range(14):
for y in range(14):
# if (537824*x + y)%104 == 78:
if (40*x + y)%104 == 78:
xyvalues.append([x,y])
for pair in xyvalues:
num14 = 'C' + str(pair[0]) + '95D' + str(pair[1])
num10 = base2base(num14, 14, 10)
print(pair, num10%104)
--------
Analytic solution:
76 base 14 is 104 base 10.
C095D0 base 14 is 6479746 base 10.
mod(6479746, 104) is 26
Cx95Dy base 14 represents our mystery number.
x000y base 14 must be 78 + 104k so that Cx95Dy base 14 is divisible by 76 base 14
14**5 is 537824
x000y base 14 is 537824x + y = 78 + 104k
or mod((537824x + y),104) = 78
mod(537824,104) = 40
mod((40x + y),104) = 78
40x + y = 78 + 104k
max LHS is 533, So k is in {0,1,2,3,4}
and RHS is in {78,182,286,390,494}
Since 40x ends in 0, y is in {0,2,4,6,8}
RHS minus corresponding y value: {70,180,280,390,490}
but of these, only 280 is divisible by 40
thus RHS is 286, x is 7, y is 6
|
Posted by Larry
on 2023-06-22 13:59:10 |