Guest User

Untitled

a guest
Nov 20th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<conio.h>
  3.  
  4. void main()
  5. {
  6. int a=0,b=1,i,c,n,p,j,d[50],k=0;
  7. printf("Enter the number of terms:");
  8. scanf("%d",&n);
  9.  
  10. printf("\n\nThe Fibonacci numbers are:\n\n%d %d ",a,b);
  11.  
  12. for(i=0;i<n-2;i++)
  13. {
  14. c=a+b;
  15. printf("%d ",c);
  16. p=c;
  17. if(p>1)
  18. {
  19. for(j=2;j<=p/2;j++)
  20. {
  21. if(p%j==0)
  22. break;
  23. }
  24. if(j>p/2)
  25. {
  26. d[k]=p;
  27. k++;
  28. }
  29. }
  30. a=b;
  31. b=c;
  32. }
  33.  
  34. printf("\n\nThe prime numbers of the fibonacci series are: ");
  35.  
  36. for(j=0;j<k;j++)
  37. printf("%d, ",d[j]);
  38.  
  39. getch( );
  40. }
Add Comment
Please, Sign In to add comment