I am trying to make a program that finds primes numbers for a public-key cryptography system. I know that a prime number is a positive integer that has no positive divisors other than 1 and itself. I want to use an approach that that takes all integers from 2 to sqrt(n)
, to tell if it divides n or not.
I have to take a "brute force" approach that takes in an integer input seed and returns the lowest prime number; prime number >= seed
.
Some examples of what I want is :
>>> prime_func(100)
101
>>> prime_func(1000)
1009
>>>prime_func(7)
7
>>>prime_func(3)
5
What I have so far is:
def prime_func(number):
START = 2
END = (number**0.5) + 1
for i in range(START, END):
if number % i == 0:
return('Composite')
else:
return number
For the return ('Composite')
part, I want it to instead return the closest prime number after that.