Casting out nines: Difference between revisions
Content added Content deleted
Basicgames (talk | contribs) |
Basicgames (talk | contribs) |
||
Line 515: | Line 515: | ||
=={{header|Craft Basic}}== |
=={{header|Craft Basic}}== |
||
<syntaxhighlight lang="basic"> |
<syntaxhighlight lang="basic">precision 4 |
||
define base = 10, c1 = 0, c2 = 0 |
|||
for k = 1 to (base ^ 2) - 1 |
|||
let c1 = c1 + 1 |
let c1 = c1 + 1 |
||
if k % (base - 1) = (k * k) % (base - 1) |
if k % (base - 1) = (k * k) % (base - 1) then |
||
let c2 = c2 + 1 |
let c2 = c2 + 1 |
||
Line 528: | Line 530: | ||
endif |
endif |
||
next k |
|||
print "trying ", c2, " numbers instead of ", c1, " numbers saves ", 100 - (100 * c2 / c1), "%" |
print "trying ", c2, " numbers instead of ", c1, " numbers saves ", 100 - (100 * c2 / c1), "%" |