I want to express my views on the topic. I respect your's views also on this topic but i just want to express myself.
Sunday, January 23, 2011
Fibonacci Series
Find the fibonacci series based on the input number. If number is 8 then it should print like 1 1 2 3 5 8 13 21
package myrnd;
public class Fibonacci {
public static void main(String[] args) {
int num = 8;
int a, b = 0, c = 1;
for (int i = 0; i < num; i++) {
System.out.print(c+" ");
a = b;
b = c;
c = a + b;
}
}
}
No comments:
Post a Comment