Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int fibo(int n){
- int fib[n];
- fib[0] = 1;
- fib[1] = 1;
- if(n==1){
- return 1;
- }else if(n==2){
- return 1;
- }else{
- for(int i = 1; i<n; i++){
- fib[i]=fib[i-1]+fib[i-2];
- }
- return fib[n-1];
- }
- }
- int main(void) {
- int n, f;
- printf("Digite o termo da sequência: ");
- scanf("%d", &n);
- f = fibo(n);
- printf("\n%d", f);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement