answersLogoWhite

0


Best Answer

#include

#include

void main()

{

int a=0,b=1,c,i=2,n;

clrscr();

printf("enter no");

scanf("%d",&n);

if(n==0)

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

else

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

while(i<=n) {

c=a+b;

printf("%d",c);

a=b;

b=c;

i++;

}

getch();

}

User Avatar

Wiki User

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

Wiki User

15y ago

int iFibOne = 0, iFibTwo = 1;

System.out.println("Fibonacci series printing ...... ");

System.out.print(iFibOne + "," + iFibTwo + ",");

do{

int cur = iFibOne + iFibTwo;

iFibOne = iFibTwo;

iFibTwo = cur;

System.out.print(cur + ",");

}while(iFibTwo < 100);

This prints up to 144 feel free to change 100 in while condition to get more.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago






This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Fibonacci series with do while in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Write a java program to print the last digit in Fibonacci series?

Just generate the Fibonacci numbers one by one, and print each number's last digit ie number%10.


Fibbomacci series using recursion shell programming?

Here is a good answer for recursion Fibonacci series. #include &lt;stdio.h&gt; #include &lt;conio.h&gt; long Fibonacci(long n); int main() { long r, n,i; printf("Enter the value of n: "); scanf("%ld",&amp;n); for(i=0;i&lt;=n;i++) { printf(" Fibonacci(%ld)= %ld\n", i,Fibonacci(i)); } getch(); return 0; } long Fibonacci(long n) { if(n==0 n==1) return n; else { return (Fibonacci(n-1)+Fibonacci(n-2)); } } for n=5; Output: Fibonacci(0)=0 Fibonacci(1)=1 Fibonacci(2)=1 Fibonacci(3)=2 Fibonacci(4)=3 Fibonacci(5)=5


What is the importance of the Fibonacci series?

The Importance of Fibonacci's series is that it helps people find more patterns 1+0=1 1+1=2 1+2=3 2+3=5 5+3=8 etc.


Java script program to Print the Fibonacci series using array?

&lt;script type = "text/javascript"&gt; var input; var rev = 0; input=window.prompt ("Please enter a 5-digit number to be reversed."); input = input * 1; while (input &gt; 0) { rev *= 10; rev += input % 10; input /= 10; } document.write ("Reversed number: " + rev); &lt;/script&gt;


Write a shell program to generate fibnacci series using while loop?

//WAP to print fibonacci series using do-while loop.? using System; class Fibonacci { public static void Main() { int a=1,b=1; int sum=0; Console.Write("Enter Limit:"); int n=Int32.Parse(Console.ReadLine()); Console.Write(a); Console.Write(b); do { sum=a+b; a=b; b=sum; Console.Write(sum); } while(sum&lt;n); } } By-Vivek Kumar Keshari