Блог пользователя olenihc

Автор olenihc, история, 10 лет назад, По-английски

Hi!

I've come across this piece of code of a (modified?) sieve and I'm trying to figure out what sieve[i] means and how it works, specially the 2nd for.

Would you help me, please?

Thanks!

  • Проголосовать: нравится
  • +16
  • Проголосовать: не нравится

»
10 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +3 Проголосовать: не нравится

sieve[i] gives you the index of the biggest prime factor. The index is one-based.

sieve[20] == 3, because 20 = 2*2*5 and primes[3] == 5 (5 is the third prime number)