wiley_pastebin

Question 19

Apr 11th, 2019
780
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.33 KB | None | 0 0
  1. #include <stdio.h>
  2. int function(int n){
  3.     int prev = 0;
  4.     int curr = 1;
  5.     int next;
  6.     int count = 2;
  7.     do{
  8.         next = prev+curr;
  9.         prev = curr;
  10.         curr = next;
  11.         count = count + 1;
  12.     }
  13.     while(count <= n);
  14.     return count;
  15. }
  16. int main(void) {
  17.     printf("%d\n",function(1));
  18.     return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment