Hello Friends, I want to print series like 0 1 1 23581321 previous two digits makes the sum next no. this is called Fybunic series in Mathematics. We have to use only one SOP statement in whole program and declare 4 variables only.
Hello! This seems like a school assignment... But I believe this code does what you want. You might need to clean it up a bit, though. <code> public final class Test3 { private static synchronized void main (String[] string) { int i, j, k, l, m, n, o, p, q, r; inner: for(i = 0, j = 0, System.out.println("NUMBERS: "), k = 0, o = 12, l = 0, p = 0, q = 0, n = 0, m = 0, r = 0; i < 15; System.out.println(), i++, j += 2) { { l = k + m; } while (true) { m = l; q++; j = r; break; } n = j + n; System.out.print(l); { p = p + o-- - o; { if(o == 11) { l++; n++; k++; }
else { k = m + p - k - q; continue inner; } } } } } } </code> //Kaspar
Hi Ikram - JUst FYI, the series you're referring to is spelled Fibonacci, after the Italian mathematician who made it popular. And I agree with Kaspar; you really should do your own homework. ------------------ Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide
Make visible what, without you, might perhaps never have been seen. - Robert Bresson
Now, now, Kaspar, be nice to the greenhorn... Ikram, Kaspar is just busting your chops, so don't even try to clean up his code. Most of us feel that it would be doing you (and your instructor) a disservice if we provide you with the solution. Try iterating by hand first. Then find a pattern. When you find a pattern, automate the iterations with a loop. If you want to do something fancy, you might even try recursion. Good Luck!
------------------ Junilu Lacar Sun Certified Programmer for the Java� 2 Platform