Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- long long int fibo(int pos) {
- long long int i, vet[2] ;
- long long int fibo ;
- vet[0] = 0 ;
- vet[1] = 1 ;
- if(!pos)
- return 0 ;
- else if(pos == 1)
- return 1 ;
- else {
- for(i=2; i<=pos; i++) {
- fibo = vet[0] + vet[1] ;
- vet[0] = vet[1] ;
- vet[1] = fibo ;
- }
- return fibo ;
- }
- }
- int main() {
- int n, i ;
- scanf("%d", &n);
- for(i=0; i<n; i++) {
- int a ;
- scanf("%d", &a);
- printf("Fib(%d) = %lld\n", a, fibo(a));
- }
- return 0 ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement