Advertisement
liftchampion

day 04 ex 04

Oct 19th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.29 KB | None | 0 0
  1. int ft_fibonacci(int nb)
  2. {
  3.     if (nb < 0)
  4.     {
  5.         return (-1);
  6.     }
  7.     if (nb == 0)
  8.     {
  9.         return (0);
  10.     }
  11.     if (nb == 1)
  12.     {
  13.         return (1);
  14.     }
  15.     if (nb == 2)
  16.     {
  17.         return (1);
  18.     }
  19.     return (ft_fibonacci(nb - 2) + ft_fibonacci(nb - 1));
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement