Sign InCoursewareNuggetsTutorials AboutClassesCodePad

MacArthur's Math Trick

This is a math trick that General Douglas MacArthur performed to entertain people. Ask your friend to write down his or her birth month and age, both as an integer. For example, if someone was born in July and the age is 18, write down 7 and 18. Then ask your friend to do the following calculation.

Month of birth: 7           
Double it: 2 * 7 = 14
Add 5: 14 + 5 = 19
Multiply by 50: 19 * 50 = 950
Add age: 950 + 18 = 968
Subtract 365: 968 - 365 = 603

Ask him to call out the result when he has it. Then you secretly add 115 to the number, which will be 603 + 115 = 718. Aha, you got his birth month and age. The first digit (or the first two if it is a four-digit number) indicates his birth month and the last two digits indicate his age. Try it with a different friend to see if it still works!

# Write a Python program to do MacArthur's Math Trick. print("Let's play a math game.") # Ask the user to enter his or her month of birth. month = int(input("Please enter your month of birth:")) # Ask the user to enter his or her age. age = int(input("Please enter your age:")) # Do the calculation and print out the result. result = (month * 2 + 5) * 50 + age - 365 print(result) # Add 115 to the result result = result + 115 # Get birth month and age from result. # Print out the birth month and age.
© CS Wonders·About·Classes·Cheatsheet