Demo entry 6324462

fibonacci

   

Submitted by anonymous on Nov 18, 2016 at 14:27
Language: C. Code size: 378 Bytes.

#include<stdio.h>

int main(){

    int termo, i, a, b, fibonacci;

    printf("Digite o termo que deseja da sequencia de Fibonacci: ");
    scanf("%d", &termo);

    printf("1");
    a = 0;
    b = 1;

    for(i = 1; i < termo; i++){
        fibonacci = a + b;
        a = b;
        b = fibonacci;
        printf(", %d", fibonacci);
    }


return 0;
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).