I am currently taking an intro to cryptography course that is using python as the language in the class.
The problem we have is quite simple, and all it is asking us to do is figure out the smallest prime divisor for some integer n passed into the function, and will return said prime number.
The IDE we are using is telling me that the program keeps getting interrupted because I am running out of memory.
Below is my code:
def smallest_prime_divisor(n):
if(n%2==0):
return 2;
for i in range(3, n):
if(n%i==0):
if(is_prime(i)):
return i;
return n;
for n in range(1,120):
x=2^n;
x+=1;
smallest_prime_divisor(x)
I don't believe the issue lies in the smallest_prime_divisor function, but somewhere in my second for loop, as I have tested quite a few numbers using just
smallest_prime_divisor(x); #where x is equal to all integers 1-20
I know this seems like a simple question but it is driving me mad that I can't seem to find the right words to search google for the correct answer.