ProjectEuler Problem 2 in IAS Machine Code


Improve your writing skills in 5 minutes a day with the Daily Writing Tips email newsletter.

If you want to learn more about the IAS computer, check this post.

The problem:

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.

The solution:

000 01201 06202
001 0F009 01201
002 0C204 21300
003 02300 10004
004 0D006 01201 
005 05203 21203
006 01201 05200
007 21201 06200
008 21200 0D000
009 01203 0D400

200 0000000001 #fibo1
201 0000000002 #fibo2
202 00003D0900 #CONSTANT 100
203 0000000000 #sum
204 0000000002 #CONSTANT 2

Leave a Reply

Your email address will not be published. Required fields are marked *