Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Zadanie 3
- * Ten program implementuje ciag fibonacciego.
- */
- #include <stdio.h>
- #include <stdlib.h>
- typedef unsigned long int ul;
- ul fib (int n) {
- /*
- * Ta funkcja zwraca n-ta liczbe fibonacciego. Nie potrzebujemy
- * super wydajnosci, wiec posluzymy sie definicja rekurencyjna.
- */
- if (n==0)
- return 0;
- if (n==1)
- return 1;
- return fib(n-1) + fib(n-2);
- }
- int main (void) {
- int i;
- printf("fib(10) = %lu\n", fib(10));
- for (i=0; fib(i)<15000 ; i++);
- printf("Nierownosc fib(n) > 15 000 jest spelniona juz dla n=%d!\n", i);
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment