Advertisement
calcpage

CH18_NewMathTester.java

Apr 27th, 2012
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.99 KB | None | 0 0
  1. public class NewMathTester
  2. {
  3.     public static void main(String[] args)
  4.     {
  5.         System.out.println("2^3 = " + NewMath.pow(2,3));
  6.         System.out.println("1.44^0.5 = " + NewMath.pow(1.44,0.5));
  7.         System.out.println("1.5^2 = " + NewMath.pow(1.5,2));
  8.  
  9.         System.out.println("5! = " + NewMath.fact(5));
  10.  
  11.         //5C3=5!/(3!*(5-3)!)=(5*4*3*2*1)/(3*2*1*2*1)=10
  12.         System.out.println("5C3 = " + NewMath.pascal(5,3));
  13.  
  14.         //1 4 6 4 1
  15.         System.out.println("pascalRow(4) = " + NewMath.pascalRow(4));
  16.  
  17.         //1
  18.         //1 1
  19.         //1 2 1
  20.         //1 3 3 1
  21.         //1 4 6 4 1
  22.         //...
  23.         System.out.println("pascalTri(7) = \n" + NewMath.pascalTri(7));
  24.  
  25.         //1 1 2 3 5 8 13 21 34 55 ...
  26.         for(int j=0; j<41; j++)
  27.         {
  28.             System.out.print("j = " + j + "\t");
  29.             System.out.println("fib(j) = " + NewMath.fib(j));
  30.         }
  31.  
  32.         //estimate phi = (1+sqrt(5))/2
  33.         for(int j=0; j<41; j++)
  34.         {
  35.             double phi = (double)NewMath.fib(j+1)/NewMath.fib(j);
  36.             System.out.print("j = " + j + "\t");
  37.             System.out.println("fib(j+1)/fib(j) = " + phi);
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement