E N D
Java Class import java.util.Scanner;public class Name{ static intAlgorithm Name (int n) {… The Algorithm … }public static void main (String[]args) {System.out.println("enter the value of n"); Scanner key1=new Scanner(System.in);int n=key1.nextInt(); long start = System.nanoTime();intans = Algorithm Name (n); long end = System.nanoTime();System.out.println(ans);System.out.println("The running time predicted by the program is " + (end - start) + " nanoseconds"); } }
Fibonacci numbers In mathematics, the Fibonacci numbersare the numbers in the following integer sequence: By definition, the first two Fibonacci numbers are 0 and 1, and each subsequent number is the sumof the previous two.In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation :with seed values
Factorial function The factorial function (symbol: !) just means to multiply a series of descending natural numbers. Examples: * 4! = 4 × 3 × 2 × 1 = 24You can easily calculate a factorial from the previous one , So the rule is:Which just says "the factorial of any number is that number times the factorial of (1 smaller than that number)", Examples: 10! = 10 × 9! Zero Factorial is interesting ... it is generally agreed that • n! = n × (n-1)! • 0! = 1 and 1! = 1