Skip to content

Instantly share code, notes, and snippets.

@harlos0517
Last active June 10, 2017 17:34
Show Gist options
  • Save harlos0517/328bb0c8af02dc4181a7edde3de6c691 to your computer and use it in GitHub Desktop.
Save harlos0517/328bb0c8af02dc4181a7edde3de6c691 to your computer and use it in GitHub Desktop.
/* Problem 3 */
#include <stdio.h>
#include <stdlib.h>
int main(){
// while 內的程式碼請再原大括號裏面排序喔!
/*請排序*/ printf("%d", fib);
/*請排序*/ while( i<=n ){
/*請排序*/ a = b;
/*請排序*/ fib = a+b;
/*請排序*/ b = fib;
/*請排序*/ i++;
}
/*請排序*/ int i, n, a, b, fib;
/*請排序*/ scanf("%d", &n);
/*請排序*/ a = b = 1;
/*請排序*/ i = 3;
system("pause");
return 0;
}
// TITLE : 求費氏數列的第n項
// INPUT : 第二題的輸出值(令為n)
// OUTPUT: 費氏數列的第n項為何?
/* 註:令費氏數列的第n項為F(n),則
F(1) = 1
F(2) = 1
F(n) = F(n-2) + F(n-1), n>2 */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment