레이블이 Fibonacci인 게시물을 표시합니다. 모든 게시물 표시
레이블이 Fibonacci인 게시물을 표시합니다. 모든 게시물 표시

2018/07/08

[c] Fibonacci

#include 

int main(){
    unsigned long a,b,cnt,i,n1,n2,n;

    scanf("%ld %ld",&a, &b);

    n2=1;
    n1=2;
    cnt=0;

    for(i=3;i=a && n<=b)
        {   
            cnt++;
            printf("cnt %ld : %ld\n", cnt, n );
        }   
        n2 = n1; 
        n1 = n;
    }   

    printf("%ld\n", cnt);
}

2016/08/27

피보나치(Fibonacci) in C


#include 

/* buff array for memorization */
int buf[10001];

/* buff array initialize */
void init(int arr[], int s){
     int i;
     buf[0]=0;
     buf[1]=1;
     buf[2]=2;
     for(i=3;i
          arr[i]=0;
     }
}

/* Fibonacci main function */
int Fibo(int i){
     if(but[i] != 0) return i; 
     return Fibo(i-1) + Fibo(i-2); 
}