Steady squares: Difference between revisions

m
→‎{{header|Tiny BASIC}}: Works with (Tom Pittman's) TinyBasic.
m (→‎{{header|Tiny BASIC}}: Works with (Tom Pittman's) TinyBasic.)
Line 380:
 
==={{header|Tiny BASIC}}===
{{works with|TinyBasic}}
Although TinyBASIC is limited to signed 16-bit integers, we can still handle the basic task by noting that we can split a four digit number into the first pair of digits and the seoncd pair. If we call these F and B say, then the number squared module 10000 is B*B + 200 * ( F*B MOD 100 ). Additionally, (as other samples have noted), we only need to consider numbers ending in 1, 5 or 6.
<syntaxhighlight lang="tinybasicbasic">
REM P = THE NUMBER TO SQUARE, WITH THE FINAL DIGIT REPLACED BY 0
REM X = THE FINAL DIGIT OF THE NUMBER, 1, 5 OR 6
Line 404 ⟶ 405:
130 IF X=9 LET X=6
140 IF P<9990 THEN GOTO 40
150 END
</syntaxhighlight>
 
511

edits