write a program to enter a number.find and print if it is a prime number or not computer
Answers
Answered by
0
Explanation:
#include<stdio.h>
int main(){
int n,i,m=0,flag=0;
printf("Enter the number to check prime:");
scanf("%d",&n);
m=n/2;
for(i=2;i<=m;i++)
{
Answered by
0
Answer:
# Program to check if a number is prime or not
num = 29
# To take input from the user
num = int(input("Enter a number: "))
# define a flag variable
flag = False
# prime numbers are greater than 1
if num > 1:
# check for factors
for i in range(2, num):
if (num % i) == 0:
# if factor is found, set flag to True
flag = True
# break out of loop
break
# check if flag is True
if flag:
print(num, "is not a prime number")
else:
print(num, "is a prime number")
Explanation:
hope it was clear, this is a python program btw
Similar questions
Math,
3 hours ago
Math,
3 hours ago
Math,
6 hours ago
Math,
6 hours ago
India Languages,
8 months ago
Computer Science,
8 months ago
Biology,
8 months ago