Babbage problem: Difference between revisions
Content deleted Content added
Cyril Nocton (talk | contribs) |
Babbage problem in Chipmunk Basic, GW-BASIC and MSX Basic |
||
Line 784: | Line 784: | ||
{{out}} |
{{out}} |
||
Identical to the first BBC BASIC version. |
Identical to the first BBC BASIC version. |
||
==={{header|Chipmunk Basic}}=== |
|||
{{works with|Chipmunk Basic|3.6.4}} |
|||
{{trans|BASIC256}} |
|||
<syntaxhighlight lang="qbasic">10 cls |
|||
20 number = 2 |
|||
30 while ((number^2) mod 1000000) <> 269696 |
|||
40 number = number+2 |
|||
50 wend |
|||
60 print "The smallest number whose square ends in 269696 is: " number |
|||
70 print "It's square is " number*number |
|||
80 end</syntaxhighlight> |
|||
==={{header|GW-BASIC}}=== |
|||
{{works with|MSX_BASIC}} |
|||
{{works with|PC-BASIC|any}} |
|||
{{trans|Applesoft BASIC}} |
|||
<syntaxhighlight lang="qbasic">10 CLS |
|||
20 DEF FN ST(A#) = N# - INT (A#) * INT (A#) |
|||
30 N# = 269696! |
|||
40 N# = N# + 1000000! |
|||
50 R# = SQR(N#) |
|||
60 IF FN ST(R#) <> 0 AND N# < 999999999# THEN GOTO 40 |
|||
70 IF N# > 999999999# THEN GOTO 110 |
|||
80 PRINT "The smallest number whose square ends in 269696 is:";R# |
|||
90 PRINT "It's square is:";N# |
|||
100 END |
|||
110 PRINT "There is no solution for values smaller than 999999999."</syntaxhighlight> |
|||
{{out}} |
|||
<pre>The smallest number whose square ends in 269696 is: 25264 |
|||
It's square is: 638269696</pre> |
|||
==={{header|MSX Basic}}=== |
|||
The [[#GW-BASIC|GW-BASIC]] solution works without any changes. |
|||
==={{header|QBasic}}=== |
==={{header|QBasic}}=== |