Post Reply 
scramble prime challenge
02-15-2020, 06:59 PM
Post: #13
RE: scramble prime challenge
(02-14-2020 10:30 PM)Don Shepherd Wrote:  
(02-14-2020 10:09 PM)John Keith Wrote:  
Code:

Spoilers...










\<< I\->NL DUP { 1. 3. 7. 9. } DIFF
  IF SIZE
  THEN DROP 0.
  ELSE DUP SIZE
    \<< NL\->I ISPRIME?
    \>> DOPERM 0. POS NOT
  END
\>>

thanks John.

What exactly does this program do, I'm not familiar with RPL.
Don

The first 3 lines check for any digits other than 1, 3, 7, or 9 and return 0 (false) if any are present. The next 3 lines create all permutations of the digits of the given number and test if they are prime. If all are prime the program returns 1 (true) else 0 (false).

The documentation for the ListExt Library (see here) explains the commands used better than I can.

As Dave Britten said above, this would get very slow for numbers with more than 6 or 7 digits. Since Albert Chan has shown that there are no scramble primes with more than 3 and less than 19 digits, it's really not that practical anyway.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
scramble prime challenge - Don Shepherd - 02-14-2020, 01:14 AM
RE: scramble prime challenge - Paul Dale - 02-14-2020, 03:02 AM
RE: scramble prime challenge - Albert Chan - 02-14-2020, 04:39 AM
RE: scramble prime challenge - Albert Chan - 02-14-2020, 04:02 PM
RE: scramble prime challenge - Paul Dale - 02-14-2020, 04:43 AM
RE: scramble prime challenge - ttw - 02-14-2020, 01:56 PM
RE: scramble prime challenge - John Keith - 02-14-2020, 10:09 PM
RE: scramble prime challenge - John Keith - 02-15-2020 06:59 PM
RE: scramble prime challenge - John Keith - 02-16-2020, 07:11 PM
RE: scramble prime challenge - Albert Chan - 02-15-2020, 02:14 PM
RE: scramble prime challenge - Albert Chan - 02-17-2020, 06:23 PM
RE: scramble prime challenge - Albert Chan - 02-19-2020, 12:16 AM
RE: scramble prime challenge - Allen - 02-15-2020, 11:11 PM
RE: scramble prime challenge - Allen - 02-16-2020, 02:19 PM



User(s) browsing this thread: 1 Guest(s)