Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. /******************************************************************************
  2.  
  3. Welcome to GDB Online.
  4. GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby,
  5. Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
  6. Code, Compile, Run and Debug online from anywhere in world.
  7.  
  8. *******************************************************************************/
  9. #include <stdio.h>
  10. #include <math.h>
  11. int fibonachi(int n[],int i)
  12. { int x,y;
  13. x=sqrt(5*n[i]*n[i]-4);
  14. y=sqrt(5*n[i]*n[i]+4);
  15. if(x*x==5*n[i]*n[i]-4||y*y==5*n[i]*n[i]+4&&n[i]%2==0)return 1;
  16. return 0;
  17. }
  18.  
  19. int main()
  20. { int i;
  21. int n[]={1,2,3,4,5,6,7,8};
  22. for(i=0;i<8;i++)
  23. {
  24. if(fibonachi(n,i)==1)printf("%d\n",n[i]);
  25. }
  26.  
  27.  
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement