Sieve of Eratosthenes - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: HP Prime Software Library (/forum-15.html) +--- Thread: Sieve of Eratosthenes (/thread-11979.html) |
Sieve of Eratosthenes - Eddie W. Shore - 12-19-2018 02:30 PM The program SIEVEMIN shows a miniature version of the famous Sieve of Eratosthenes. The Sieve of Eratosthenes is a Greek algorithm that determines prime numbers from 2 to N through eliminating multiplies. Code: sub1(); // subroutine Blog link: https://edspi31415.blogspot.com/2018/12/hp-prime-and-ti-84-plus-sieve-of.html RE: Sieve of Eratosthenes - grsbanks - 12-19-2018 03:24 PM I remember doing something similar to solve one of the early puzzles on the Project Euler website RE: Sieve of Eratosthenes - Albert Chan - 12-19-2018 07:00 PM (12-19-2018 02:30 PM)Eddie W. Shore Wrote: FOR K FROM 2 TO 7 DO I don't think the code is really a prime sieve. A true sieve does not need any divisibility test. Also, looping count is very high = 6x7x7 = 294 I think sieve should be like below code. To get your 7x7 matrix, do list2mat(sieve(7*7), 7) PHP Code: sieve(n) := { RE: Sieve of Eratosthenes - Thomas Klemm - 12-20-2018 06:19 AM There is a program written by C.Ret for the HP-29C and also for the HP-41C that uses a min-heap as data-structure instead of an array due to memory limitations. Cheers Thomas |