Computer Science, asked by vijaykumar9984078984, 4 months ago

Write a program to input any number of digits and display all non prime digits
INPUT:724
OUTPUT:4​

Answers

Answered by pritampankaj05
3

Answer:

import java.util.*;

class abc

{

   public static void main(String args[])

    {

         int n=724;     // you can also make it user input

         int r=1;

         while(n!=0)

          {

               r=n%10;

               prime(r);

               n=n/10;

          }

  }

  int prime(int no)

  {

      int c=0;

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

      {

         if(no%i==0)

              c++;

      }

      if(c==2)

          System.out.print(no+" ");

  }

           

     

Explanation:

Similar questions