Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
27
Task/Babbage-problem/Modula-2/babbage-problem.mod2
Normal file
27
Task/Babbage-problem/Modula-2/babbage-problem.mod2
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
MODULE BabbageProblem;
|
||||
FROM FormatString IMPORT FormatString;
|
||||
FROM RealMath IMPORT sqrt;
|
||||
FROM Terminal IMPORT WriteString,ReadChar;
|
||||
|
||||
VAR
|
||||
buf : ARRAY[0..63] OF CHAR;
|
||||
k : INTEGER;
|
||||
BEGIN
|
||||
(* Find the greatest integer less than the square root *)
|
||||
k := TRUNC(sqrt(269696.0));
|
||||
|
||||
(* Odd numbers cannot be solutions, so decrement *)
|
||||
IF k MOD 2 = 1 THEN
|
||||
DEC(k);
|
||||
END;
|
||||
|
||||
(* Find a number that meets the criteria *)
|
||||
WHILE (k*k) MOD 1000000 # 269696 DO
|
||||
INC(k,2)
|
||||
END;
|
||||
|
||||
FormatString("%i * %i = %i", buf, k, k, k*k);
|
||||
WriteString(buf);
|
||||
|
||||
ReadChar
|
||||
END BabbageProblem.
|
||||
Loading…
Add table
Add a link
Reference in a new issue