Babbage problem: Difference between revisions

m (→‎{{header|Wren}}: Minor tidy)
 
(3 intermediate revisions by 2 users not shown)
Line 1,790:
=={{header|Elena}}==
{{trans|Smalltalk}}
ELENA 46.x :
<syntaxhighlight lang="elena">import extensions;
import system'math;
Line 1,798:
var n := 1;
until(n.sqr().mod:(1000000) == 269696)
{
n += 1
Line 2,798:
{{out}}
<pre>{{x->25264},{x->99736}}</pre>
 
 
=={{header|Tiny Craft BasicMATLAB}}==
<syntaxhighlight lang="basicMATLAB">10 print "calculating..."
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
60 print " fprintf('The smallest numberpositive integer whose square ends in 269696 is:= "%d\n', nx);
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..."
 
20 let n = 2
 
30 rem do
 
40 let n = n + 2
 
50 if (n ^ 2) % 1000000 <> 269696 then 30
 
60 print "The smallest number whose square ends in 269696 is: ", n
70 print "It's square is ", n * n</syntaxhighlight>
 
=={{header|Transd}}==
305

edits