Problem 12

7 comments on “Problem 12”


  • Gourav

    n=int(input())
    flag=False
    for j in range (2,n):
    if(n%j==0):
    flag=True
    break
    if(flag):
    print(‘Not a prime’)
    else:
    print(‘yes i is a prime’)


  • shushank

    n=int(input())
    c=0
    if n>1:
    for i in range(2,n):
    a1=i
    if n%i==0:
    c=1
    break
    if c==0:
    print(“Prime Number”)
    else:
    print(“Not Prime Number”)
    else:
    print(“Not Prime Number”)


  • Anand

    def prime(a):
    a=a
    for i in range(2,a):
    if a%i==0:
    count=1
    break
    else:
    count=0
    return(count)

    if __name__==”__main__”:
    a=int(input(“Please enter the number”))
    if a<=0:
    print("Please enter a positive number")
    elif a==1:
    print(a,"is a prime number")
    elif a==2:
    print(a,"is a prime number")
    else:
    count1=prime(a)
    if count1==1:
    print(a,"is not a prime number")
    elif count1==0:
    print(a,"is a prime number")


  • Raman

    // Online C compiler to run C program online
    #include

    int main() {
    int x,c=0;
    scanf(“%d”,&x);
    int i;
    for(i=2;i<x;i++){
    if(x%i==0)
    c=1;
    }
    if(c==0 || x==2){
    printf("its a prime number");
    }
    else{
    printf("its a not prime number");
    }

    return 0;
    }


  • Mohd Saif

    #python

    n=int(input(“Enter the no:\n”))
    if(n>1):
    for i in range(2,n):
    if(n%i==0):
    print(f”{n} is not a prime number”)
    break
    else:
    print(f”{n} is a prime number”)
    else:
    print(f”{n} is not a prime number”)


    • Daipayan

      public static void main(String[] args) {
      int n = Integer.parseInt(args[0]);
      if (n == 2 || n == 3) {
      System.out.println(“composite”);
      return;
      }
      if (n % 2 == 0 || n % 3 == 0) {
      System.out.println(“composite”);
      return;
      }
      for (int i = 5; i * i <= n; i = i + 6) {
      if (n % i == 0) {
      System.out.println("composite");
      return;
      }
      }
      System.out.println("prime");
      }