class area { public static void main(String args[]) { int area, length, breadth; length=10; breadth=29; area=breadth* length; System.out.println(area); }}
// a number is said to binary if all the digit should be either zero or one ex-1011 binary number ex-1201 not binary number class binary { public static void main(String args[]) { int no=125,b=0,e=0; while(no>0) { b=n0%10; no=no/10; if(b>1) { e=1; break; } } if(e==0) System.out.println("the number is binary"); else System.out.println("the number is not binary"); } }
// if a number is present at the end of its square ex- 25 sqr=625 (25 is present at the end of 625) class automerphic { public static void main(String args[]) { int no=125, sqr=0,b=0,c=0,e=0; sqr=no* no; while(no>0 && sqr>0) { b=n0%10; no=no/10; c=sqr%10; sqr=sqr/10; if( b !=c) { e=1; // e is the marking symbol break; }} if(e==0) System.out.println("automerphic"); else System.out.println("not auto merphic"); } }
// if the addition of cube of all the digit of a number is same as original number ex- 153 1^3+5^3+3^3=153 class amstrong { public static void main(String args[]) { int no=125, sum=0,copy=0,b=0; while(no>0) { b=n0%10; no=no/10; sum=sum+b * b * b; } if(copy= =sum) System.out.println("amstrong number"); else System.out.println("not amstrong"); } }
// if the reverse of a number is same as original number then the number is palindrome // ex- a=121 ans -121 a=125 ans -521 is not palindrome class palindrome { public static void main(String args[]) { int no=125, rev=0,b=0 copy=no; while(no>0) { b=n0%10; no=no/10; rev=rev *10+b; } if(copy==rev) System.out.println("palindrome"); else System.out.println("not palindrome"); } }
// factorial of a number 5!= 5*4*3*2*1 =120 class factorial { public static void main(String args[]) { int no=10,fact=1; for(int i=1; i<=no ; i++) { fact=fact*i; } System.out.println(fact); }}
//if the addition of factors of a number except that number is same as original number then the number is perfect ex n0=6 factor 1,2,3 that means 1+2+3=6 then it is perfect number class perfect { public static void main(String args[]) { int no=10,sum=0; for(int i=1; i<no ; i++) { if(no%i==0) // i is the factor of that number { sum=sum+i } } if(sum==no) System.out.println("perfect number"); else System.out.println("not"); }}
class prime { public static void main(String args[]) { int no=10,count=0; for(int i=1; i<=no ; i++) { if(no%i==0) // i is the factor of that number { count++; } } if(count==2) System.out.println("prime no"); else System.out.println("composite no"); }}