Sum of square and cube digits of an integer are primes: Difference between revisions
Sum of square and cube digits of an integer are primes (view source)
Revision as of 01:51, 28 February 2023
, 1 year ago→{{header|Tiny BASIC}}: Works with (Tom Pittman's) TinyBasic
(Dialects of BASIC moved to the BASIC section.) |
m (→{{header|Tiny BASIC}}: Works with (Tom Pittman's) TinyBasic) |
||
Line 178:
==={{header|Tiny BASIC}}===
{{works with|TinyBasic}}
This can only go up to 31 because 32^3 is too big to fit in a signed 16-bit int.
<syntaxhighlight lang="
20 REM
30 REM D, the digital sum of its square or cube
40 REM
50 REM
190 REM Calculate sum of digits
20 LET D = 0▼
220 LET D =
230 LET T =
240 GOTO 210
30 LET Z = 0▼
250 REM Check if is prime
▲ IF D < 2 THEN RETURN
31 LET T = T + 2▼
▲ IF (D/T)*T=D THEN RETURN
340 IF T * T > D THEN GOTO
350 IF (D / T) * T = D THEN RETURN
360 GOTO 330
RETURN</syntaxhighlight>▼
{{out}}<pre>▼
▲{{out}}<pre>16
17
25
|