fibonacci
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include <stdio.h> int fibonacci (int number) { if (!number) return 0; else if (number == 1) return 1; return fibonacci (number - 1) + fibonacci (number - 2); } int main (int argc, char** argv) { int input = 10; int loop = 0; for (loop = 0; loop < input; loop++) { printf ("%d\n", fibonacci (loop)); } return 0; } | cs |
0 개의 댓글:
댓글 쓰기