Fibonacci series each member is the sum of the last two terms except the first and second term.
The following C program prints the members of the Fibonacci series upto a certain number, given by the user.
PROGRAM:
/*************************** *******FIBONACCI*********** 2017 (c) Manas Sharma - https://bragitoff.com **************************/ #include<stdio.h> void fibonacci(int n){ int x[2]; int y; x[0]=0; x[1]=1; printf("\n0\n1"); y=x[0]+x[1]; while(y<=n){ printf("\n%d",y); x[0]=x[1]; x[1]=y; y=x[0]+x[1]; } } main(){ int n; printf("Enter a number till which you want to generate Fibonacci numbers:\n"); scanf("%d",&n); printf("\nThe Fibonacci numbers till %d are: \n",n); fibonacci(n); }
OUTPUT:
Ph.D. researcher at Friedrich-Schiller University Jena, Germany. I’m a physicist specializing in computational material science. I write efficient codes for simulating light-matter interactions at atomic scales. I like to develop Physics, DFT, and Machine Learning related apps and software from time to time. Can code in most of the popular languages. I like to share my knowledge in Physics and applications using this Blog and a YouTube channel.
[wpedon id="7041" align="center"]