This assignment is due as follows: 10% value toward your final grade providing y
ID: 3898235 • Letter: T
Question
This assignment is due as follows: 10% value toward your final grade providing you submit it before 10PM Today June 6, 2018, 5% value toward your final grade providing you submit it before 6PM June 11, 2018. pro r fin one h Fibonacci sequence: Definition: The following is a Fibonacci sequence with 13 elements. 0,1,1,2,3,5,8,13,21,34,55,89,144, hence the FN element is 13. sec s d The first two numbers in the Fibonacci sequence are 0 and 1 and each subsequent number is the sum of the previous two. e: The sequence FN of Fibonacci numbers is defined by the recurrence relation: FN (F N-1) (F N-2) with initial values of F1 0,F2 1. Write an assembly routine that enables the user to enter two digits number. Thereafter the program will display the Fibonacci sequence with the entered two digits number be it FN element. For example if the user enters 15 then FN 15 the sequence that the program displays shall be up to the 15th element as follows: 0,1,1,2,3,5,8,13,21,34,55,89,144, 233,377Explanation / Answer
import java.util.ArrayList;
class fibnocci1
{
public static void main(String args[])
{
Stringsum=numAsFibnocci(515);
System.out.println(sum);
Sum=numAsFibonacci(13);
System.out.println(sum);
}
public static string numAsFibnocci(int n)
{
String str=" ";
if(n<=2)
{
str +=n;
return str;
}
else
{
int maxfib=fibnocci(n);
str +=maxfib;
return str +(!" ".equals(str)?"+":" ")+ numAsFibnocci(n_maxfib);
}
}public static int fibnocci(int maxnum)
{
int n1=0,n2=1,n3=0;
int i=0;
while(n3<=maxnum)
{
n3=n2+n1;
n1=n2;
n2=n3;
if(n1+n2>maxnum)
break;
}
return n3;
}
OUTPUT:javac fibnocci1.java
java fibnacci1
377+ 89+ 34+ 13+ 2
13+ 0