import java.math.BigInteger;
public class Tnumber{
public static void main (String []args){
BigInteger first=BigInteger.valueOf(0),second=BigInteger.valueOf(1), third=BigInteger.valueOf(1),sum=BigInteger.valueOf(0);
int c=0;
System.out.println("First 1600 Tribonacci Number is =\n" + first);
System.out.println(second);
System.out.println(third);
while(c<1600){
sum=first.add(second).add(third);
System.out.println(sum);
first=second;
second=third;
third=sum;
c++;
}
}
}
Like this programme you can also create the programme of Tetranacci Number, Pentanacci Number, Hexanacci Number, Heptanacci Number etc.
You can take help from: http://mathworld.wolfram.com/Fibonaccin-StepNumber.html
Hi! Really Great Post!
ReplyDeleteI don't know if you use Linux, but if you like in linux you have Kate, an application that allows you to insert your code and export it as html with the proper identation and word's colors.
Like here:
http://utopia555.blogspot.com/2009/06/alien-numbers-code-jam.html
Bye!