//  Data Structures with Java by John R. Hubbard
//  Copyright McGraw-Hill, 2001
//  Problem 4.01 on page 87
//  Recursive Function returns sum of first n squares


public class Pr0401
{ public static void main(String[] args)
  { for (int n = 0 ; n < 10; n++)
     System.out.println("sum(" + n + ") = " + sum(n));
  }
  public static int sum(int n)
  { if (n==0) return 0;     // basis
     return sum(n-1) + n*n;  // recursion
  }
}
