Prime Num

    0

    0

    Pritam Borole

    The code prints "Prime" if the number is prime and "Not Prime" otherwise.

    class Main{
      public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        boolean prime = true;
        if(n==1){
          System.out.println("Not Prime");
        }else{
        for(int i=2;i<n;i++){
          if(n%i==0){
            prime = false;
            break;
          }
        }
        if(prime){
          System.out.println("Prime");
        }else{
          System.out.println("Not Prime");
        }
        
          }
      
      }
    
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.