In 2006, a teacher said to his class, an American hero
was born X years ago and died at age
Y, where Y minus its reverse equals
the square of the cube root of (X - Y).
If half the hero's birth year is a prime number whose birthday was the teacher referring to, and what anniversary was 2006?
Today is January 17th.
Benjamin Franklin was born on January 17, 1706.
-----------
Program output:
Our hero was born in 1706, died in 1790 at the age of 84.
So, 2006 was the 300-th year anniversary of his birth.
Benjamin Franklin
-----------
birth_years = [2*i for i in range(0, 1004) if isprime(i)]
for birth in birth_years:
x = 2006 - birth
for y in range(0, 121):
rev_y = int(str(y)[::-1])
diff = y - rev_y
if not iscube(x-y):
continue
z = round(((x-y)**2)**(1/3))
if diff != z:
continue
death = birth + y
print('Our hero was born in {}, died in {} at the age of {}. {}So, 2006 was the {}-th year anniversary of his birth.'.format(birth, death, y, '\n', x))
|
Posted by Larry
on 2025-01-17 16:20:43 |