Skip to main content

Program in Java to check a number is protoneon number or not. A protoneon number is a number who sum of the digits of the number is a prime number.

Program in Java to check a number is protoneon number or not.
A protoneon number is a number who sum of the digits of the number is a prime number.


Example

Input : Enter a number: 16

Sum of the digits: 7

so 7 is a prime number. Thus 16 is a protoneon number


import java.util.Scanner;
class protoneon
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter a number:");
int n=sc.nextInt();
int s=0,c=0;
while(n>0)
{
int d=n%10;
s=s+d;
n=n/10;
}
for(int i=1;i<=s;i++)
{
if(s%i==0)
{
c=c+1;
}
}
if(c==2)
System.out.println("Protoneon Number");
else
System.out.println("Non-Protonenon Number");
}
}

Popular posts from this blog