answersLogoWhite

0


Best Answer

class Fibonacci

{

public static void main(String args[])

{

System.out.println("enter the number upto u want");

int number=Integer.parseInt(args[0]);

int a=0,b=1,c=0;

System.out.print(a+" "+b);

for(int i=1;i<=number;i++)

{

c=a+b;

System.out.print(c+" ");

a=b;

b=c;

}

}

}

the number are given to the run time where are print the series eg: 5

0 1 1 2 3 5 8 13................

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a java program to generate the Fibonacci Series using for loop?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write a c program Fibonacci series using for loop in java?

Exactly what do you mean by 'C program in Java'


Write a c program to generate Fibonacci series using copy constructor?

#include #include void main(void) { int i,j,k,n; clrscr(); i=0; j=1; printf("%d %d ",i,j); for(n=0;n&lt;=5;n++) { k=i+j; i=j; j=k; printf("%d ",k); } getch(); }


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.


Write a program using while loop that generates Fabonaci series up to 200?

//to generate Fibonacci series upto a range of 200....(in C).... #include&lt;stdio.h&gt; main() { int a,b,c,i; a=0; b=1; printf("\n FIBONACCI SERIES .....\t"); i=1; while(i&lt;=(200-2)) { c=a+b; printf("\t%d",c); a=b; b=c; i++; } }


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


Write a c program to accept a numbers and generate square root cube and exponential values?

write a c program to accept a number and generate a square root cube and exponential values


Write a java program to print the result in the series?

If you have the series stored in an array, you loop through the array and print each array element in turn. Another possibility is to print out the numbers in the series as you generate them. In that case, you may not need to store anything (depending on the series, of course).


Algorithm of Fibonacci series in c?

#include&lt;stdio.h&gt; #include&lt;conio.h&gt; int fib(int a); main() { int a; clrscr(); scanf("%d",&amp;a); for(int i=0;i&lt;a;i++) printf("%d\n",fib(i)); } int fib(int a) { if(a==0) return 0; if(a==1) return 1; else return (fib(a-1)+fib(a-2)); }


How do you write a program to print Fibonacci series of n numbers using recursion in cpp?

#include&lt;iostream&gt; unsigned fib (unsigned term, unsigned a=0, unsigned b=1) { if (term&lt;1) return a; return fib (--term, a+b, a); } int main() { std::cout &lt;&lt; "Fibonacci (1000th term): " &lt;&lt; fib (1000) &lt;&lt; std::endl; }


Write a C program to print the following series 112 122 . 1n2?

write a program to print the series 1/12+1/22+.........+1/n2 ?


Write a Fibonacci function then takes an input from the user in main program and pass to function which prints Fibonacci series up to this number in c language by using while statement?

#include#includevoid fibonacci(int x){int f=0,m=-1,n=1,i=0;while(i


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