composite number

 composite number


Problem Description


Java Program to check for composite number


Solution.,


import java.util.Scanner;

import java.io.*;

public class TestClass {

public static void main(String[] args) { 

Scanner sc= new Scanner(System.in); 

int a= sc.nextInt();

int p=a;

int i,c=0;

for(i=2;i<a;i++)

{

if(a%i==0)

{

c++;

}

}

if(c>1)

{  

System.out.println("yes");

        }

        else

        {

            System.out.println("no");

        }

}

}


Post a Comment

0 Comments