Pages

Tuesday, September 8, 2009

Euler Problem 25 solution

Time (s): ~0.001
package margusmartseppcode.From_20_to_29;

public class Problem_25 {
 public static void main(String[] args) {
  // Binet's Fibonacci Number Formula
  double digits = 1000;
  double result = Math.ceil((digits - 1 + Math.log10(5) / 2)
    / Math.log10((1 + Math.sqrt(5)) / 2));
  System.out.println((int) result);
 }
}

No comments:

Post a Comment