• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Fybunic series

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
High Plains Drifter
Posts: 7289
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
reply
    Bookmark Topic Watch Topic
  • New Topic