Elektrine lite

← Feed

@wiert@mastodon.social

Post #1540112

2026-04-22 14:06 UTC

@electron_greg @Robsonde @EdS Modified code: ``` 10 N=20: L=INT(10*N/3): DIM A(255): Z$="000000":T$="999999" 20 FOR I=1 TO L: A(I)=2: NEXT I: M=0: P=0: FOR J=1 TO N: Q=0: K=2*L+1 30 FOR I=L TO 1 STEP -1: K=K-2: X=10*A(I)+Q*I: Q=INT(X/K): A(I)=X-Q*K: NEXT I 40 Y =INT(Q/10): A(1)=Q-10*Y: Q=Y: IF Q=9 THEN LET M=M+1: GOTO 70 50 IF Q=10 THEN PRINT STR$(P+1);LEFT$(Z$,M);: P=0: M=0: GOTO 70 60 PRINT STR$(P);: IF M>0 THEN PRINT LEFT$(T$,M); 65 P=Q: M=0 70 NEXT J:PRINT STR$(P) ```

Replies (1)

  • @wiert@mastodon.social 2026-04-22 14:10

    @electron_greg @Robsonde @EdS The code also runs (much faster!) in the JavaScript Applesoft BASIC emulator at https://www.calormen.com/jsbasic/ I had to add zeros to the line numbers so I could split original line 6 in 60 and 65, plus adding the `IF M>0` check. Not sure why the `P=Q: M=0` bit had to move to line 65: my Applesoft BASIC knowledge is from 40+ years ago. With lines 65 and 60 combined, the result would wrongly be `000000922222297933333`. Oddly, lines 40 and 50 work without splitting.

    Open ##1540113