Example 1 find power:
package demo_programs;
public class Find_power {
private boolean find_prime(int no) {
// TODO Auto-generated method stub
int div = 2;
while(div
Example 2 Find common divisors
package demo_programs;
public class Find_CommonDivisors {
public static void main(String[] args) {
// TODO Auto-generated method stub
Find_CommonDivisors find=new Find_CommonDivisors();
find.find_divisors(100, 120);
}
private void find_divisors(int no1, int no2) {
// TODO Auto-generated method stub
int div =2;
int small=0;
while (div<=small) {
if( no1%div==0 && no2%div==0);
System.out.println(div);
div+=1;
}
}
}
Example 3 LCM
package demo_programs;
public class LCM_01 {
int no1 =3, no2 = 30;
int big = no1>no2 ? no1:no2;{
// while (true){
if (big%no1 == 0 && big%no2 == 0);
System.out.println("LCM is" + big);
big+=1;}
}