evenFibonnacci
sums of all of the even Fibonacci number starting at
given postion to its limits, saving in the total
evenFibonacci(position, limit, total)
position | The current position |
---|---|
limit | The wanted position |
total | The accumulated value |
The calculated result
This function has the following complexity O($n^2$)
evenFibonacci(0, 10, 10)#> [1] 20evenFibonacci(5, 50, 50)#> [1] 92evenFibonacci(50, 1000, 870)#> [1] 870