answersLogoWhite

0


Best Answer

#include<stdio.h> #include<conio.h> void fibo(int); void main() { int num; clrscr(); printf("\n\t Enter number of elements in series : "); scanf("%d",&num); if(num>0) fibo(num); else printf("\n\t Please enter positive number "); } void fibo(int num) { int a=0,b=1,c=0; if(num==1) printf("\n%d",a); if(num>=2) printf("\n%d\t%d\t",a,b); for(;num>2;num--) { c=a+b; a=b; b=c; printf("%3d\t",c); } getch(); }

User Avatar

Wiki User

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

12y ago

#include <stdio.h>

#include <conio.h>

int fab(int);

main()

{

int n,i;

printf("enter the value of n\n");

scanf("%d",&n);

for(i=1;i<=n;i++)

{

printf("%d\n",fab(i));

}

getch();

}

int fab(int n)

{

if(n==1)

return 1;

else if(n==2)

return 1;

else

return fab(n-1)+fab(n-2);

}

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

This program prints the Fibonacci series

#include<stdio.h>

#include<conio.h>

void main(void)

{

int i,j,k,n;

clrscr();

i=0;

j=1;

printf("%d %d ",i,j);

for(n=0;n<=5;n++)

{

k=i+j;

i=j;

j=k;

printf("%d ",k);

}

getch();

}

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

#include <stdio.h>

int main(int argc, char **argv)

{

if (argc < 3) {

printf("Usage: %s min max\n", argv[0]);

return -1;

}

int a = 1, b = 1, c;

int min = atoi(argv[1]), max = atoi(argv[2]);

if (min <= 1)

printf("%d %d ", a, b);

while (b < max) {

c = a + b;

a = b;

b = c;

if ((b >= min) && (b <= max))

printf("%d ", b);

}

printf("\n");

return 0;

}

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

Fibonacci numbers grow very fast. For instance, term 49 has value 4,807,526,976, whichs exceeds the limit (4,294,967,295) of a 32 bit unsigned integer, and term 95 has value 19,740,274,219,868,200,000, which exceeds the limit (18,446,744,073,709,551,615) of a 64 bit unsigned integer. Any program that calculates large Fibonacci numbers must deal with this limitation, and that is much more involved than just the algorithm to generate the numbers. (T0 = 0, T1 = 1, TN(>1) = TN-2 + TN-1) In order to properly generate large Fibonacci numbers, you need to use, or develop, a large integer/decimal class, such as an arbitrary length decimal class. One way to do this is to create a class that contains a linked list, each element containing one digit or integer. Then you create methods that allow, in this case, addition, of classes using the rules of arithmetic with carry. Its the same as writing it down on paper.

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

Fibonacci number grow large quickly, and soon exceed the bounds of the computer's binary representation. With 32-bit unsigned integers, the maximum Fibonacci number is the 48th term, or 2,971,215,073. With 64-bit unsigned integers, the maximum Fibonacci number is the 94th term, or 12,200,160,415,121,876,738. To get larger terms, you need an arbitrary length decimal math library.

Here is a program using 64-bit integers. It works on the Microsoft Windows SDK 7. The long long datatype and the %I64u format specification might not be ANSI portable.

#include

int main (int argc, char *argv[]) {

int n, i;

unsigned long long a=0,b=1,c;

if (argc < 2) {

fprintf (stderr, "Usage: fib1 N\n");

return 1;

} else n = atoi (argv[1]);

printf ("%d\n",a);

for (i = 2; i <= n; i ++) {

c = a + b;

printf ("%I64u\n", c);

b = a;

a = c;

}

return 0;

}
main()

{

int a=0,b=1;

int d;

printf("1 : %d\n2 : %d",a,b);

for (i=3; i<50; i++)

{

d=a+b;

a=b;

b=d;

printf("%d : %d\n",i,d);

}

getch();

}

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

// recursive method

unsigned long fib (unsigned long n) {

if (n 2) return 1;

return fib (n-1) + fib (n-2);

}

// iterative method

unsigned long fib (unsigned long n) {

unsigned long N[3] = { 0, 1, 1 };

if (n <=3) return N[n-1];

while (n > 3) {

N[0] = N[1];

N[1] = N[2];

N[2] = N[0] + N[1];

--n;

}

return N[2];

}

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program to print first 'n' Fibonacci 100 numbers?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Write a java script program to print first ten odd natural numbers in C?

Q.1 Write a program to print first ten odd natural numbers. Q.2 Write a program to input a number. Print their table. Q.3 Write a function to print a factorial value.


Write a program to generate the Fibonacci series using non-recursive method?

In c: int fibr(int n) { // Find nth Fibonacci number using recursion. if (n&lt;=2) return 1; // the first two Fibonacci numbers are 1 and 1 return (fibr(n-2)+fibr(n-1)); } int fibi(int n) { // Find nth Fibonacci number using iteration. int temp,last=1,f=1; int i; for (i=3;i&lt;n;++i) { // the first two Fibonacci numbers are 1 and 1 temp=f; f+=last; last=temp; } return f; }


How do you write the code for generating Fibonacci search in C programming?

Use a lookup table. The first two elements are 0 and 1 and each subsequent element is the sum of the preceding two elements. The table needn't be very large as there are only 43 Fibonacci numbers in the range 0 to 1 billion. If you need larger numbers, use long doubles.


How do you write a program to find out the square and cube of first ten natural numbers in gw basic?

First you will need to have some basic programming knowledge. You can use this to help make the program that is needed.


Program in 'c' to find the LCM of any given five numbers?

Just write a method or function that calculates the LCM for two numbers at a time. Then calculate the LCM for the first two numbers, get the LCM of the result with the third number, etc.Just write a method or function that calculates the LCM for two numbers at a time. Then calculate the LCM for the first two numbers, get the LCM of the result with the third number, etc.Just write a method or function that calculates the LCM for two numbers at a time. Then calculate the LCM for the first two numbers, get the LCM of the result with the third number, etc.Just write a method or function that calculates the LCM for two numbers at a time. Then calculate the LCM for the first two numbers, get the LCM of the result with the third number, etc.

Related questions

What are the first 85 Fibonacci numbers?

The first 85 Fibonacci numbers are:011235813213455891442333776109871,5972,5844,1816,76510,94617,71128,65746,36875,025121,393196,418317,811514,229832,0401,346,2692,178,3093,524,5785,702,8879,227,46514,930,35224,157,81739,088,16963,245,986102,334,155165,580,141267,914,296433,494,437701,408,7331,134,903,1701,836,311,9032,971,215,0734,807,526,9767,778,742,04912,586,269,02520,365,011,07432,951,280,09953,316,291,17386,267,571,272139,583,862,445225,851,433,717365,435,296,162591,286,729,879956,722,026,0411,548,008,755,9202,504,730,781,9614,052,739,537,8816,557,470,319,84210,610,209,857,72317,167,680,177,56527,777,890,035,28844,945,570,212,85372,723,460,248,141117,669,030,460,994190,392,490,709,135308,061,521,170,129498,454,011,879,264806,515,533,049,3931,304,969,544,928,6572,111,485,077,978,0503,416,454,622,906,7075,527,939,700,884,7578,944,394,323,791,46414,472,334,024,676,22123,416,728,348,467,68537,889,062,373,143,90661,305,790,721,611,59199,194,853,094,755,497160,500,643,816,367,088


Is 13 a Fibonacci number?

the first seven Fibonacci numbers are 1,1,2,3,5,8,13. 13 is a Fibonacci number.


When did Leonardo Fibonacci discovered the Fibonacci numbers?

Leonardo Fibonacci first recorded his sequence in his book Liber Abaci, which was published in 1202.


What are the first 3 numbers of the Fibonacci numbers sequence?

1, 1 and 2


What is one way to decide if two numbers follow a Fibonacci sequence?

They will always follow some Fibonacci sequence. If P and Q are any two numbers, then they belong to the Fibonacci sequence with the first two numbers as P and (Q-P).


What are the 11 Fibonacci numbers?

The first 11 Fibonacci numbers are 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, and 55.


Did Fibonacci discover the Fibonacci numbers?

He was not the first to discover it. Fibonacci lived around 1200 AD. He might have discovered it independently but it was known in India from 200 BC.


Write a java script program to print first ten odd natural numbers in C?

Q.1 Write a program to print first ten odd natural numbers. Q.2 Write a program to input a number. Print their table. Q.3 Write a function to print a factorial value.


What are the first three numbers in the Fibonacci sequence?

1, 1 and 2


How many of the first 30 numbers of the Fibonacci sequence are odd?

20 of them.


Write a javascript program for Fibonacci series?

I did this as an answre to some common js questions , the question wasWrite a function which will return you first two times 1, then 2, then 3, then 5 and so on (Fibonacci numbers). Don't use any global variables.var fibonacci = (function () {var arr = [0, 1];return function () {var num = arr[arr.length - 1],len = arr.length;arr.push(arr[len - 1] + arr[len - 2]);return num;};}());//testvar i;for (i = 0; i < 10; i++) {console.log(fibonacci());}//1,1,2,3,5,8,13,21,34,55


Where did the Fibonacci Numbers first appear?

Fibonacci numbers have always been around. Many scholars believe the concept was first noticed by mathematicians of India. Leonardo of Pisa (known as Fibonacci) first introduced the sequence to Western European mathematics in a 1202 book entitled LiberAbici, thus the sequence bears his name.