Site hosted by Angelfire.com: Build your free website today!

Fib Num

If you wish to view the code only, check this page. You can click the links and it should open up in a notepad file.

 

class FibNum{
static public void main (String args[])
{
long A1=1;
long A2=1;
long A3;
int n;
int HowMany=10;


System.out.println("We be working with those Fib numbers ya mon.");
System.out.println("Fibonnaci number 1 is "+A1);
System.out.println("Fibonnaci number 2 is "+A2);

for(n=3; n<=HowMany; n++)
{
A3=A1+A2;

System.out.println("Fibonnaci number "+ n +" is "+ A3);
A1=A2;
A2=A3;
}
}
}

 

 

 

New Terms!

Long: The long integer type holds 64-bits of data and is always an integer.