Closure in RPL
|
11-19-2022, 04:31 PM
(This post was last modified: 11-19-2022 04:35 PM by Thomas Klemm.)
Post: #3
|
|||
|
|||
RE: Closure in RPL
I was goofing around with a filter I could use with DOSUBS to remove all multiples of a number n.
So I tried to write a program that creates it based on that number as input. Since that didn't work, I moved this part into a program that does it: Code: \<< \-> p n Let's say we call this program SIEVE. Then we start with a list of numbers: K ENTER ENTER 2 887 1 SEQ { 2 3 4 5 6 7 8 9 10 … 887 } Now we can remove all multiples of primes with: 2 SIEVE { 2 3 5 7 9 11 13 15 17 … 887 } 3 SIEVE { 2 3 5 7 11 13 17 19 23 … 887 } 5 SIEVE { 2 3 5 7 11 13 17 19 23 … 887 } Just continue with the next prime in the list. … We can stop at \(31\) since \(31^2 > 887\). 31 SIEVE { 2 3 5 7 11 13 17 19 23 … 887 } This list of primes can then be reversed and transformed into an array: [ 887 883 881 877 … 7 5 3 2 ] It is the input for the following program: Code: \<< PROOT OBJ\-> OBJ\-> DROP \->LIST .806513599261 Thanks for your reply and your suggestions. As you can see I could still solve the problem. I was just wondering if maybe I missed an obvious solution. |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Closure in RPL - Thomas Klemm - 11-19-2022, 10:29 AM
RE: Closure in RPL - DavidM - 11-19-2022, 01:42 PM
RE: Closure in RPL - Thomas Klemm - 11-19-2022 04:31 PM
RE: Closure in RPL - John Keith - 11-19-2022, 08:53 PM
RE: Closure in RPL - John Keith - 11-19-2022, 09:50 PM
RE: Closure in RPL - Thomas Klemm - 11-20-2022, 02:29 AM
RE: Closure in RPL - Albert Chan - 11-20-2022, 09:11 PM
RE: Closure in RPL - John Keith - 11-20-2022, 06:48 PM
RE: Closure in RPL - Thomas Klemm - 11-20-2022, 08:18 PM
RE: Closure in RPL - Thomas Klemm - 11-20-2022, 10:51 PM
RE: Closure in RPL - Albert Chan - 11-22-2022, 10:41 AM
|
User(s) browsing this thread: 4 Guest(s)