Computer Science, asked by sobanaayyalusamy1, 10 months ago

accept a number X as input if X is a prime print prime if X is not prime then print odd if X is an odd number if X is not prime then print even if X is an even number

Answers

Answered by ShabdSwaroop
1

import java.util.*;

class digit

{

   public static void main(String args[])

   {

       Scanner sc = new Scanner(System.in);

       int c = 0;

       int x = sc.nextInt();

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

       {

       if(x%i == 0)

       c++;

       }

       if(c == 2)

       System.out.println("Prime");

       else if(c != 2)

       {

           if(x%2 != 0)

           System.out.println("odd");

           else

           System.out.println("even");

       }

   }

}

Hope it helps :)

Similar questions