write an algorithm to display the prime number from 2 to 47
Share
write an algorithm to display the prime number from 2 to 47
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Verified answer
Answer:
There is only a single even prime number i.e. 2.
There is only one pair of consecutive prime numbers i.e. (2,3).
You can express all prime numbers in the form of 6k+1 or 6k-1 (where k is a natural number). 2 and 3 are the only exceptions that do not lie in this case.
All even natural numbers can be represented as the sum of two prime numbers. 2 is the exceptional case here.
Lemoine’s Conjecture: According to this theorem, an odd integer n (where n > 5) can be represented in the form: (odd prime + even semiprime). A number is said to be a semiprime if it can be represented as a product of two prime numbers.
Fermat’s Little Theorem: According to this theorem, for any prime number n, there lies a number p in the range [1, n) such that,
pn-1 ≡ 1 (mod n)
OR
pn-1 % n = 1
Prime Number Theorem: According to this theorem, the probability of a randomly selected number n to be a prime is inversely proportional to the log(n) or the digits in the number n.
Wilson’s Theorem: According to this theorem, a natural number n (where n >1) is said to be a prime number if and only if the following conditions hold true.
(n - 1) ! ≡ -1 mod n
OR
(n - 1) ! ≡ (n-1) mod n
C Program for Prime Numbers Using For Loop
Algorithm to Find Prime Number
STEP 1: Take num as input.
STEP 2: Initialize a variable temp to 0.
STEP 3: Iterate a “for” loop from 2 to num/2.
STEP 4: If num is divisible by loop iterator, then increment temp.
STEP 5: If the temp is equal to 0,
Return “Num IS PRIME”.
Else,
Return “Num IS NOT PRIME”.
Pseudocode to Find Prime Number
Start
Input num
Initialize variable temp = 0
FOR loop = 2 to num/2
IF num is divisible by loop
Increment temp