Problem – Fibbonaci numbers
-
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. Find the sum of all the even fibonnaci numbers below 100
-
Recipe
ingredients:
1, 2 (starting numbers) list
2 (even number)
steps:
1. add last two numbers of list write the result and add it to list if result < 100 otherwise go to step 4
2. check if the result is even (if it ends with 0,2,4,6,8) and add to sum
3. go to step 1 and exit if the result is greater than 100
4. print sum
Problem: Factors
100 => 2,4,5,10,20,25,50
39 => 3, 13
ingredient:
number
steps:
1. start from index 2 till number/2 (number-1)
2. check if number is divisibe by index and if yes write down the index
Like this:
Like Loading...