Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
22
Task/Babbage-problem/MiniScript/babbage-problem.mini
Normal file
22
Task/Babbage-problem/MiniScript/babbage-problem.mini
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
// Lines that start with "//" are "comments" that are ignored
|
||||
// by the computer. We use them to explain the code.
|
||||
|
||||
// Start by finding the smallest number that could possibly
|
||||
// square to 269696. sqrt() returns the square root of a
|
||||
// number, and floor() truncates any fractional part.
|
||||
k = floor(sqrt(269696))
|
||||
|
||||
// Since 269696 is even, we are only going to consider even
|
||||
// roots. We use the % (modulo) operator, which returns the
|
||||
// remainder after division, to tell if k is odd; if so, we
|
||||
// add 1 to make it even.
|
||||
if k % 2 == 1 then k = k + 1
|
||||
|
||||
// Now we count up by 2 from k, until we find a number that,
|
||||
// when squared, ends in 269696 (using % again).
|
||||
while k^2 % 1000000 != 269696
|
||||
k = k + 2
|
||||
end while
|
||||
|
||||
// The first such number we find is our answer.
|
||||
print k + "^2 = " + k^2
|
||||
Loading…
Add table
Add a link
Reference in a new issue