0% found this document useful (0 votes)
24 views6 pages

Sol Pract. Exam. 24-25 (Numbers Only)

Soln of java

Uploaded by

rizviabbas752
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views6 pages

Sol Pract. Exam. 24-25 (Numbers Only)

Soln of java

Uploaded by

rizviabbas752
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

import java.util.

*;

class Question3

public static void main(String args[])

Scanner sc=new Scanner(System.in);

System.out.println("Enter M (100 to 10000) and N (<100) :");

int M=sc.nextInt();

int N=sc.nextInt();

if(M>=100 && M<=10000 && N<100)

int sum,c,num=M+1;

do

int t=num,digit=0;

sum=c=0;

while(t!=0)

digit=t%10;

sum=sum+digit;

c++;

t=t/10;

num++;

}while(sum!=N);

System.out.println("The required number = "+(num-1));

System.out.println("Total number of digits = "+c);

else
System.out.println("INVALID INPUT");

*************************************************************************************************

import java.util.*;

class Question6

public static void main(String args[])

Scanner sc=new Scanner(System.in);

System.out.println("Enter the value of m and n (m<n)");

int m=sc.nextInt();

int n=sc.nextInt();

if(m<n)

int count=0;

System.out.print("THE COMPOSITE MAGIC INTEGERS ARE:");

for(int num=m;num<=n;num++)

int factor=0;

for(int i=1;i<=num;i++)

if(num%i==0)

factor++;

int t=num,sum=0,digit=0;

while(t!=0)

{
digit=t%10;

sum=sum+digit;

t=t/10;

/** condition for magic number: sum of digits mod 9 gives 1*/

if(factor>2 && sum%9==1)

System.out.print(num+",");

count++;

System.out.print("\nFREQUENCY OF COMPOSITE MAGIC IS:"+count);

else

System.out.println("INVALID INPUT");

import java.util.*;

class Question11

public static void main(String args[])

Scanner sc=new Scanner(System.in);

System.out.println("Enter the value of m(<3000) and n(<3000 & m<n)");

int m=sc.nextInt();

int n=sc.nextInt();

if(m<n)

{
int count=0;

System.out.print("THE PRIME PALINDROME INTEGERS ARE:");

for(int num=m;num<=n;num++)

int factor=0;

for(int i=1;i<=num;i++)

if(num%i==0)

factor++;

int t=num,rev=0,digit=0;

while(t!=0)

digit=t%10;

rev=rev*10+digit;

t=t/10;

if(factor==2 && num==rev)

System.out.print(num+",");

count++;

System.out.print("\nFREQUENCY OF PRIME PALINDROME IS:"+count);

else

System.out.println("INVALID INPUT");

}
import java.util.*;

class Question13

public static void main(String args[])

Scanner sc=new Scanner(System.in);

System.out.println("Enter the value of p(<5000) and q(<5000) (p<q)");

int p=sc.nextInt();

int q=sc.nextInt();

if(p<q && q<5000 && p<5000)

int count=0;

System.out.print("THE KAPREKAR NUMBERS ARE:");

for(int n=p;n<=q;n++)

int square=n*n;

int c=0,t=n;

while(t!=0)

c++;

t=t/10;

int right=square%((int)Math.pow(10,c)); // right part

int left=square/((int)Math.pow(10,c)); // left part

int sum=right+left;

if(sum==n)

System.out.print(n+",");
count++;

System.out.print("\nFREQUENCY OF KAPREKAR NUMBERS IS:"+count);

else

System.out.println("Invalid input");

You might also like