This community-built FAQ covers the “Fibonacci Finder” code challenge in Java. You can find that challenge here, or pick any challenge you like from our list.
Top Discussions on the Java challenge Fibonacci Finder
There are currently no frequently asked questions or top answers associated with this challenge – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this challenge. Ask a question or post a solution by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this challenge, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
You can also find further discussion and get answers to your questions over in #get-help.
Agree with a comment or answer? Like () to up-vote the contribution!
public class FibonacciFinder {
public static void main(String args) {
System.out.print(fibFinder(6));
}
public static int fibFinder(int n) {
// Write your code here
double a = 1 + Math.pow(5,0.5);
double b = 1 - Math.pow(5,0.5);
double x = (Math.pow(a,n) - Math.pow(b,n)) / (Math.pow(2,n) * (a - 1));
return (int)x;
}
}