#include <stdio.h>
int fibSum10( int n, int a, int b)
{
int t, sum = 0 ;
while ( -- n)
{
t = a;
a = b;
b += t;
// sum += b;
}
sum = b;
n = 10 ;
while ( -- n)
{
t = a;
a = b;
b += t;
sum += b;
}
return sum;
}
int main( )
{
for ( int i
= 1 ; i
< 10 ; ++ i
) printf ( "n = %d, sum = %d\n " , i
, fibSum10
( i
, 0 , 1 ) ) ; return 0 ;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgZmliU3VtMTAoaW50IG4sIGludCBhLCBpbnQgYikKewogICAgaW50IHQsIHN1bSA9IDA7CiAgICB3aGlsZSAoLS1uKQogICAgewogICAgICAgIHQgPSBhOwogICAgICAgIGEgPSBiOwogICAgICAgIGIgKz0gdDsKICAgICAgICAvLyBzdW0gKz0gYjsKICAgIH0KICAgIHN1bSA9IGI7CiAgICBuID0gMTA7CiAgICB3aGlsZSAoLS1uKQogICAgewogICAgICAgIHQgPSBhOwogICAgICAgIGEgPSBiOwogICAgICAgIGIgKz0gdDsKICAgICAgICBzdW0gKz0gYjsKICAgIH0KICAgIHJldHVybiBzdW07Cn0KCmludCBtYWluKCkKewogICAgZm9yIChpbnQgaSA9IDE7IGkgPCAxMDsgKytpKSBwcmludGYoIm4gPSAlZCwgc3VtID0gJWRcbiIsIGksIGZpYlN1bTEwKGksIDAsIDEpKTsKICAgIHJldHVybiAwOwp9Cg==
stdout
n = 1, sum = 143
n = 2, sum = 231
n = 3, sum = 374
n = 4, sum = 605
n = 5, sum = 979
n = 6, sum = 1584
n = 7, sum = 2563
n = 8, sum = 4147
n = 9, sum = 6710