Babbage problem: Difference between revisions
→{{header|Tiny Craft Basic}}
m (→{{header|Wren}}: Minor tidy) |
Basicgames (talk | contribs) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1,790:
=={{header|Elena}}==
{{trans|Smalltalk}}
ELENA
<syntaxhighlight lang="elena">import extensions;
import system'math;
Line 1,798:
var n := 1;
until(n.sqr().mod
{
n += 1
Line 2,798:
{{out}}
<pre>{{x->25264},{x->99736}}</pre>
clear all;close all;clc;
BabbageProblem();
function BabbageProblem
% Initialize x to 524, as the square root of 269696 is approximately 519.something
x = 524;
% Loop until the square of x modulo 1000000 equals 269696
while mod(x^2, 1000000) ~= 269696
% If the last digit of x is 4, increment x by 2
% Otherwise, increment x by 8
if mod(x, 10) == 4
x = x + 2;
else
x = x + 8;
end
end
% Display the result
end
</syntaxhighlight>
{{out}}
<pre>
The smallest positive integer whose square ends in 269696 = 25264
</pre>
=={{header|Maxima}}==
Line 4,606 ⟶ 4,636:
638269696
</pre>
▲=={{header|Tiny Craft Basic}}==
▲<syntaxhighlight lang="basic">10 print "calculating..."
▲60 print "The smallest number whose square ends in 269696 is: ", n
=={{header|Transd}}==
|