Pages

Friday, October 13, 2023

Flowchart to check prime number

Prime Number

" a whole number greater than 1 that cannot be exactly divided by any whole number other than itself and 1 (e.g. 2, 3, 5, 7, 11)."

Prime numbers are very useful in cryptography.

Flowchart to check a Prime Number

Following flowchart is prepared using a RAPTOR software.
Prime number Flowchart

Python Logic to check a prime number.

def is_prime(n):
  if n <= 1:
    return False
  for i in range(2, int(n**0.5) + 1):
    if n % i == 0:
      return False
  return True

Output of python program:

is_prime(5)
True



No comments:

Post a Comment