Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
32
Task/Babbage-problem/S-BASIC/babbage-problem.basic
Normal file
32
Task/Babbage-problem/S-BASIC/babbage-problem.basic
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
$lines
|
||||
|
||||
$constant true = FFFFH
|
||||
$constant false = 0
|
||||
|
||||
var n, sq, r = real.double
|
||||
var done = integer
|
||||
|
||||
print "Finding smallest number whose square ends in 269696"
|
||||
|
||||
n = 520 rem - no smaller number has a square that large
|
||||
done = false
|
||||
|
||||
rem - no need to search beyond the number Babbage already knew
|
||||
while not done and n <= 99736.0 do
|
||||
begin
|
||||
sq = n * n
|
||||
rem - compute sq mod 1000000 by repeated subtraction
|
||||
r = sq
|
||||
while r >= 1000000.0 do
|
||||
r = r - 1000000.0
|
||||
if r = 269696.0 then
|
||||
begin
|
||||
print using "The smallest number is ######"; n
|
||||
print using "and its square is ##,###,###,###"; sq
|
||||
done = true
|
||||
end
|
||||
rem - only even numbers can have a square ending in 6
|
||||
n = n + 2
|
||||
end
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue