Interview Question
Country: United States
Interview Type: Phone Interview
a simplest code will look like this:
int f,f1,f2;
f1=0,f2=1;
for(i=0;i<7;i++)
{
f=f1+f2;
f1=f2;
f2=f
printf("%d",f);
}
public void fibo(int low, int high){
int[] arr = new int[];
arr[0] = 0;
arr[1] = 1;
if(arr[0] >= low && arr[0] <= high){
System.out.print(arr[0] + " ");
}
if(arr[1] >= low && arr[1] <= high){
System.out.print(arr[1] + " ");
}
int i = 2;
while(arr[i] <= high){
arr[i] = arr[i-1] + arr[i-2];
if(arr[i] >= low && arr[i] <= high){
System.out.print(arr[i] + " ");
}
i++;
}
}
C# Solution
- DrFrag February 05, 2013