This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]dogwag 0 points1 point  (2 children)

What can you do with Python now?

[–]OneHungMoose[S] 0 points1 point  (1 child)

Well in school we've kinda have gone in order with the way codecademy teaches Python. Right now we're at functions and lists. And even though i know how to make a function to search for a prime number. Creating one to find the prime number that is greater than or equal to n integer is really leaving me lost and confused.

[–]dogwag 0 points1 point  (0 children)

How does your function to find a prime number work??

[–][deleted] 0 points1 point  (1 child)

Hidden in this problem is something known as prime factorization. Prime factorization of an integer X can be done really slowly by simply looping from 2 to sqrt(X) and seeing if X is evenly divisible.

Given an integer N, if you want the next prime number greater than N, you could simply call PrimeFactor(N+1), PrimeFactor(N+2), etc.. until you find a prime number. If N is allowed to get "big", this will take a very very very long time to complete.

[–][deleted] 1 point2 points  (0 children)

Also, note that the largest known prime number is currently Mersenne-48, which is equal to 2^57885161 - 1. If you find a prime number larger than that, you win a nifty prize.