1

I'm relatively inexperienced with Python, and I'm attempting to convert an old prime number sieve script I made on Scratch to the Python language.

The original Scratch script has a portion that goes like this:

repeat until item Divisor of PrimeList * item Divisor of PrimeList > NumberBeingChecked:
    if NumberBeingChecked mod item Divisor of Primes = 0 then:
        set PrimeStatus to false

The function of item Divisor of PrimeList is to recall an element of the given list, PrimeList, that is equal to the given variable Divisor (which begins as 1 and increases for every iteration of the loop). It's then used to check if the NBC is evenly divisible, and repeats & increases until the square of Divisor is larger than the NBC.

For my Python script, I need an equivalent function, but am unsure of how to implement it. I previously attempted to use primes [divisor] but that did not work. The code itself works, but using the function would allow for optimization.

Any help would be appreciated!

0 Answers0