How to resolve the algorithm Babbage problem step by step in the Limbo programming language
How to resolve the algorithm Babbage problem step by step in the Limbo programming language
Table of Contents
Problem Statement
Charles Babbage, looking ahead to the sorts of problems his Analytical Engine would be able to solve, gave this example: He thought the answer might be 99,736, whose square is 9,947,269,696; but he couldn't be certain.
The task is to find out if Babbage had the right answer — and to do so, as far as your language allows it, in code that Babbage himself would have been able to read and understand. As Babbage evidently solved the task with pencil and paper, a similar efficient solution is preferred. For these purposes, Charles Babbage may be taken to be an intelligent person, familiar with mathematics and with the idea of a computer; he has written the first drafts of simple computer programmes in tabular form. [Babbage Archive Series L].
The aim of the task is to write a program that is sufficiently clear and well-documented for such a person to be able to read it and be confident that it does indeed solve the specified problem.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Babbage problem step by step in the Limbo programming language
Source code in the limbo programming language
implement Babbage;
include "sys.m";
sys: Sys;
print: import sys;
include "draw.m";
draw: Draw;
Babbage : module
{
init : fn(ctxt : ref Draw->Context, args : list of string);
};
init (ctxt: ref Draw->Context, args: list of string)
{
sys = load Sys Sys->PATH;
current := 0;
while ((current * current) % 1000000 != 269696)
current++;
print("%d", current);
}
You may also check:How to resolve the algorithm Enumerations step by step in the Ruby programming language
You may also check:How to resolve the algorithm RSA code step by step in the C# programming language
You may also check:How to resolve the algorithm Active object step by step in the Perl programming language
You may also check:How to resolve the algorithm Horner's rule for polynomial evaluation step by step in the Seed7 programming language
You may also check:How to resolve the algorithm Ethiopian multiplication step by step in the CLU programming language