(49G) OEIS A028907
11-22-2014, 04:17 PM (This post was last modified: 06-15-2017 01:44 PM by Gene.)
Post: #1
 Gerald H Senior Member Posts: 1,627 Joined: May 2014
(49G) OEIS A028907
From the Online Encyclopaedia of Integer Sequences:

A028907 Arrange digits of squares in ascending order.

0, 1, 4, 9, 16, 25, 36, 49, 46, 18, 1, 112, 144, 169, 169, 225, 256, 289, 234, 136, 4, 144, 448, 259, 567, 256, 667, 279, 478, 148, 9, 169

Just for fun on the 49G, works with Vers 1.19-6 & 2.10-7:

::
CK1&Dispatch
# FF
::
FPTR2 ^DupQIsZero?
?SEMI
NULL$SWAP FPTR2 ^ZSQ_ FPTR2 ^Z>S BINT10 ONE_DO INDEX@ #>$
NULL$FPTR F 1A COERCEDUP #0=ITE DROP :: ROTSWAP ZERO_DO JINDEX@ #>$
&\$
LOOP
SWAP
;
LOOP
DROP
FPTR2 ^S>Z
;
;
@

Enter the index & the value is returned.
01-28-2024, 08:14 PM
Post: #2
 AerobarSW Junior Member Posts: 1 Joined: Jan 2024
RE: (49G) OEIS A028907
Also for fun, 2 UserRPL versions:
1/ for HP-49/50
Code:
 « SQ    IF DUP 9 > THEN       { }       WHILE OVER REPEAT           SWAP 10 IDIV2 ROT +        END       NIP SORT       « SWAP 10 * + » STREAM     END  » 'A028907' STO
2/ for HP-28, without calling a sort function:
Code:
 « SQ { }    WHILE OVER REPEAT        SWAP 10 MOD LAST / IP SWAP ROT +     END    1    WHILE DUP 9 ≤ REPEAT       WHILE DUP2 POS REPEAT          LAST ROT SWAP 0 PUT          ROT 10 * ROT SWAP OVER + ROT ROT       END       1 +    END DROP2  » 'A028907' STO
My old HP-28S runs it only 3 times slower than my Hp-50g does.
01-29-2024, 03:52 PM
Post: #3
 mfleming Senior Member Posts: 946 Joined: Jul 2015
RE: (49G) OEIS A028907
I'm sure there's a better APL expression, but I have a pretty poor handicap in code golf

Code:
       OEIS_A028907←{10⊥a[⍋a←(10⍴⍨(≢⍕)⍵)⊤⍵]}       OEIS_A028907 321 123       (¯1+⍳32)*2 0 1 4 9 16 25 36 49 64 81 100 121 144 169 196 225 256 289 324 361 400 441 484 529 576 625 676 729 784 841 900 961       OEIS_A028907¨(¯1+⍳32)*2 0 1 4 9 16 25 36 49 46 18 1 112 144 169 169 225 256 289 234 136 4 144 448 259 567 256 667 279 478 148 9 169
(Beware the mangled Tally symbol next to Thorn)

Remember kids, "In a democracy, you get the government you deserve."
 « Next Oldest | Next Newest »