/* NetRexx */ options replace format comments java crossref symbols nobinary utf8 numeric digits 5000 -- set up numeric precision babbageNr = babbage() -- call a function to perform the analysis and capture the result babbageSq = babbageNr ** 2 -- calculate the square of the result -- display results using a library function System.out.printf("%,10d\u00b2 == %,12d%n", [Integer(babbageNr), Integer(babbageSq)]) return -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- A function method to answer Babbage's question: -- "What is the smallest positive integer whose square ends in the digits 269,696?" -- — Babbage, letter to Lord Bowden, 1837; -- see Hollingdale and Tootill, Electronic Computers, second edition, 1970, p. 125. -- (He thought the answer might be 99,736, whose square is 9,947,269,696; but he couldn't be certain.) method babbage() public static binary n = int 104 -- (integer arithmatic) -- begin a processing loop to determine the value -- starting point: 104 loop while ((n * n) // 1000000) \= 269696 -- loop continues while the remainder of n squared divided by 1,000,000 is not equal to 269,696 if n // 10 == 4 then do -- increment n by 2 if the remainder of n divided by 10 equals 4 n = n + 2 end if n // 10 == 6 then do -- increment n by 8 if the remainder of n divided by 10 equals 6 n = n + 8 end end return n -- end the function and return the result