python - How to create Fibonacci Sequence in Java -


I actually suck into math. I mean, I'm really trying to make the class a simple Fibonacci sequence I suck an algorithm on mathematics I, I've seen examples of Python, which looks something like this:

 < Code> a = 0b = 1 while B & lt; 10: Print B A, B = B, B + A  

The problem is that I really can not do this work in any other language. I would like to work in Java, because I can translate there from the languages ​​I am using from there. This is a general idea:

  public class Fibonacci algorithm {private integer a = 0; Private integer B = 1; Public Fibonacci algorithm () {} public integer increments () {a = b; B = A + B; return value; } Public Integer getValue () {Return b; }}  

Whatever I finish, it is doubling, which I can do with multiplication: (Can anyone help me? Mathematics told me.

I will do it like this:

  public class Fibonacci algorithm {private int A = 0; private Int B public = 1; public Fbiansia algorithm () {} public Int Inrgment () {EIT Tempp = B, B = A + B; A = TMP; return value;} common Nick Act Value () {Return B;}}  

This puts it as close to your original Java code.

[Editor's note : Integers to ints . for Integers is no reason to use.]


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -