Computer Science, asked by Anonymous, 11 months ago

Write a program to input a number and check whether it is a prime number or not ​

Answers

Answered by ashissingharoy2
3

Explanation:

10 cls

20 rem

30 input " enter a no. " ; n

40 let c = c + 1

50 if n mod c = 0 then f = f + 1

60 if c less than n then goto 40

70 if f = 2 then print " prime " ; n else print " not prime " ; n

80 end

Answered by Anonymous
5

Answer:

import java.util.*;

public class Number

{

public static void main(String args[])

{

Scanner in=new Scanner(System.in);

int a,n,c;

System.out.println("Enter the number");

a=in.nextInt();

for(n=2;n=a/2;n++)

{

c=(a%n);

if(c==0)

{

System.out.println("It is a composite number");

else

System.out.println("It is a prime number");

}

}

}

}

Explanation:

● A prime number is that which is divisible by itself and by 1.

● As the program is reparative so we should use loop here such as for loop.

● A number whether it is prime or composite but never gets divided by number which is more than its half.

Similar questions