You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
583 B
Java

public class Tfibo implements Runnable {
private int[] inputnumbers;
private int[] outputnumbers;
//constructor to define a parameter to the class
public Tfibo(int[] inputnumbers, int[] outputnumbers){
this.inputnumbers = inputnumbers;
this.outputnumbers = outputnumbers;
}
public void run(){
int n1= inputnumbers[0];
int n2= inputnumbers[1];
int n3,i,count=10;
outputnumbers[0] = n1;
outputnumbers[1] = n2;
//do the math
for(i=2;i<count;++i){
n3=n1+n2;
outputnumbers[i] = n3;
n1=n2;
n2=n3;
}
}
}