java-exercises-1 (1)
java-exercises-1 (1)
Methods:
1. public static boolean isPerfectNumber(int n);
a perfect number is a positive integer that is equal to the sum of
its positive divisors, excluding the number itself.
all its factors except the number itself, returns true if the given
number is a perfect number else returns false
2. public static long factorial(int n);
returns factorial of the given number
3. public static boolean isPrime(int n);
4. public static long sumOfPrimes(int n);
returns sum of primes numbers between 1 to n.
Note: Invoke isPrime() within this method
5. public static boolean isArmstrongNumber(int n);
returns true if the given number is armstrong number else
returns false.
if number is 3-digit number say "xyz", armstrong number is
xyz==cube of x+cube of y+cube of z
Ex. n=10
0 1 1 2 3 5 8 13 21 34
0+1+1+2+3+5+8 + 13+21+34 = 88
2. com.ey.ui
Tester Class Name: MyMathDemo
Test the methods of MyMath class