Post Reply 
newRPL: Alpha demo 0.9 released [UPDATED 2017-10-25]
10-26-2017, 09:05 PM (This post was last modified: 10-26-2017 10:55 PM by Gilles59.)
Post: #207
RE: newRPL: Alpha demo 0.9 released [UPDATED 2017-10-25]
Hi,

Here is a program to find the numbers that are equal to the sum of the cubes of their digits

New RPL Version :
Code:
«
0 9 FOR 'a'
 0 9 FOR 'b'
  0 9 FOR 'c'
   IF 'a*100+b*10+c==a^3+b^3+c^3' THEN {a b c } EVAL END
  NEXT
 NEXT
NEXT
»
TEVAL : 1,06 sec

UserRPL version
Code:

«
0. 9. FOR a
 0. 9. FOR b
  0. 9. FOR c
   IF 'a*100.+b*10.+c==a^3.+b^3.+c^3.' THEN a b c 3. ->LIST END
  NEXT
 NEXT
NEXT
»
TEVAL : 289 sec (slow both in real or exact)

An other way en NewRPL :
Code:
<< 0 999 FOR 'n' n DUP ->STR UTF8-> #30h - 3 ^ ΣLIST == n IFT NEXT >>
TEVAL : 1,56"

UserRPL with GoferList lib (exact mode only):
Code:
 0 999 1 Seq « DUP ->STR Chars STR-> 3 ^ Sum ==  » Filter
TEVAL : who cares ? ;D
EDIT : Surprisingly, faster than previous UserRPL in 201 sec.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: newRPL: Alpha demo 0.9 released [UPDATED 2017-10-25] - Gilles59 - 10-26-2017 09:05 PM



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