17 lines
265 B
C
17 lines
265 B
C
int num = 15;
|
|
int result = -1;
|
|
|
|
if (num < 2)
|
|
result = num;
|
|
else {
|
|
int prev1 = 1;
|
|
int prev2 = 0;
|
|
for (int i=2; i < num; i++)
|
|
{
|
|
int tmp = prev1;
|
|
prev1 = prev1 + prev2;
|
|
prev2 = tmp;
|
|
};
|
|
result = prev1+prev2;
|
|
}
|
|
result; |