"Fibonacci Sequence III"
Given the first few Fibonacci numbers:
1 1 2 3 5 8 13 ...
What is the sum of the first 75 Fibonacci numbers?
As an example above, the sum of the first 7 numbers is 33.
Well this challenge was simple... simply modify the loop from challenge 13, and add a counter that gets added to each time.
Awnser:
5527939700884756
Source:
function solution(){
$result = 2;
$prevno = 1; // no 1
$currno = 1; // no 2
for( $i = 1; $i <= 73; $i++ ){
$placeholder = bcadd($prevno, $currno);
$prevno = $currno;
$currno = $placeholder;
$result = bcadd($result, $currno);
}
echo "".$result."";
}