Python includes exercises 21
Title: Monkey eating peach issues: the monkey off his first day of a number of peach, half eaten immediately, not addiction, but also eat a morning in turn eaten by the remaining peach half, then eat a . After the morning ate the day before the rest of the half a zero. Day 10 in the morning when you want to eat, see only one peach. Seeking first day of the total number picked.
Program analysis: take the method of reverse thinking, inferred from the forward.
Source Code:
#!/usr/bin/python # -*- coding: UTF-8 -*- x2 = 1 for day in range(9,0,-1): x1 = (x2 + 1) * 2 x2 = x1 print x1
The above example output is:
1534