Each of M and N is a
nonnegative integer such that:
M
o Celsius = N
o Fahrenheit.
Determine all possible values of N<10
such that N is a perfect power.
*** F = (9/5)*C +32, where F denotes degree Fahrenheit and C denotes degree Celsius.
I think there must be a typo in the problem, because if M >= 0 and N >= 0 there are no such integers, let alone perfect powers. For any Fahrenheit temp below 32, the Celsius value is negative.
So I tested Celsius values from -17 up to +10^7 degrees C.
[(0, 32), 2],
[(1120, 2048), 2],
[(43385, 78125), 5],
[(72800, 131072), 2],
[(89455, 161051), 11],
[(4660320, 8388608), 2]
----------
def c2f(n):
if (n*9/5 + 32)%1 == 0:
return int(n*9/5 + 32)
else:
return n*9/5 + 32
def f2c(n):
if ((n-32)*5/9)%1 == 0:
return int((n-32)*5/9)
else:
return (n-32)*5/9
def isPower(x,power=None):
import math
ans = [False, power]
if x%1 != 0:
return [False, power]
limit = int(x**.5)
for expo in range(2,limit +1):
if (math.log(x,expo))%1 == 0:
ans = [True,expo]
return ans
ans = []
for cel in range(-17,10**7 ):
fah = c2f(cel)
if isPower(fah)[0]:
ans.append([(cel, c2f(cel)), isPower(c2f(cel))[1]])
print((cel, c2f(cel)), isPower(c2f(cel))[1])
Edited on January 26, 2025, 11:47 am
|
Posted by Larry
on 2022-01-09 10:17:05 |