We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
publicclassSolution{publicstaticvoidmain(String[]args){/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */inti,n;BigIntegera,b;Scannersc=newScanner(System.in);a=sc.nextBigInteger();b=sc.nextBigInteger();n=sc.nextInt();BigInteger[]val=newBigInteger[n];val[0]=a;val[1]=b;for(i=2;i<n;i++){val[i]=(val[i-1].pow(2)).add(val[i-2]);}System.out.println(val[i-1]);}}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Fibonacci Modified
You are viewing a single comment's thread. Return to all comments →