title: The golden ratio in java
body: <p>Consider the sequence X1=1, X2= 1+1/1, X3= 1+1/1+1/1... . In this sequence Xn+1 = 1+1/Xn (for n>= 1). Write a method in Java that computes Xn. As n increases, the terms of this sequence get closer and closer to the golden ratio 1+sqrt 5/ 2 ~ 1.61803398875. How close is X10 to the golden ratio?</p>
  
  <p>This is the program that I have written but when I run it in java it does not compile. I do not know what to do and it is due tomorrow. Please help!</p>
  
  <pre><code>public class Golden Ratio
  </code></pre>
  
  <p>{</p>
  
  <pre><code>public static final double GOLDEN = ( 1 + Math.sqrt(5))/2;
  /**
   * precondition: Class(Golden Ratio), n values 
   * precondition: sequence values found
   */
  public static double sequence (int n)
  {
  if (n == 0) {
  return 1;
  {
  public static void main(String[] args)
  {
  for (int n = 0; n &lt; 40; n++)
  {
  double diff = Math.abs(sequence(n) - GOLDEN);
  System.out.print(n+1+")");
  System.out.print(n + 1 &lt; 10 ? " seq " + sequence(n): "seq " + sequence (n))
  System.out.print("gld " + GOLDEN);
  System.out.print("diff = %.32f\t". diff);
  System.out.print("\n");
  }
  System.out.print("\n");
  System.out.print("10)" + "sqe " + sequence(9) + "ln gld + GOLDEN"\t diff = %.32 f\t" + diff);
  System.out.print("");
  }
  }
  }
  </code></pre>