Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class NewMathTester
- {
- public static void main(String[] args)
- {
- System.out.println("2^3 = " + NewMath.pow(2,3));
- System.out.println("1.44^0.5 = " + NewMath.pow(1.44,0.5));
- System.out.println("1.5^2 = " + NewMath.pow(1.5,2));
- System.out.println("5! = " + NewMath.fact(5));
- //5C3=5!/(3!*(5-3)!)=(5*4*3*2*1)/(3*2*1*2*1)=10
- System.out.println("5C3 = " + NewMath.pascal(5,3));
- //1 4 6 4 1
- System.out.println("pascalRow(4) = " + NewMath.pascalRow(4));
- //1
- //1 1
- //1 2 1
- //1 3 3 1
- //1 4 6 4 1
- //...
- System.out.println("pascalTri(7) = \n" + NewMath.pascalTri(7));
- //1 1 2 3 5 8 13 21 34 55 ...
- for(int j=0; j<41; j++)
- {
- System.out.print("j = " + j + "\t");
- System.out.println("fib(j) = " + NewMath.fib(j));
- }
- //estimate phi = (1+sqrt(5))/2
- for(int j=0; j<41; j++)
- {
- double phi = (double)NewMath.fib(j+1)/NewMath.fib(j);
- System.out.print("j = " + j + "\t");
- System.out.println("fib(j+1)/fib(j) = " + phi);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement