Advertisement
Cherro

fibonnaci dobrze

Jan 22nd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.32 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int fib(int n);
  5.  
  6. int main()
  7. {
  8.     int wej;
  9.     puts("Ktory wyraz z ciagu Fibonacciego podac?\n");
  10.     scanf("%d",&wej);
  11.     printf("%d",fib(wej));
  12.     return 0;
  13. }
  14.  
  15.  
  16. int fib(int n)
  17. {
  18.  
  19.     if(n == 0) return 0;
  20.     if(n == 1) return 1;
  21.     return fib(n-1)+fib(n-2);
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement