So after having been distracted by other projects, I finally made good on my holiday goal of learning Python. After having read the John Zelle book (ref my earlier post 2 months ago), I starting practicing Python by solving math problems on project euler, a community based interest group online for people who like math and programming. Here are a few results:
Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, …
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
So there you go. While I managed to solve the problems, I used so many lines of code compared to the model answer. I took an average of 2 hours to do each problem. The process can be painful and frustrating at times, but the satisfaction is definitely there when you managed to solve it. And not to mention that this is a surefire way to learn Python!