Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: bbcctxp
Problemset: อนุกรม
Language: c
Time: 0.002 second
Submitted On: 2025-10-10 14:48:29
#include <stdio.h>
//1 1 2 3 5 8 13 21
long long fib(int n){
long long a = 0, b = 1;
long temp;
if (n<=0) return 0;
for(int i = 1; i<n; i++){
temp = a+b;
a=b;
b=temp;
}
return b;
}
int main(){
int n;
scanf("%d", &n);
printf("%lld", fib(n));
return 0;
}