Babbage problem: Difference between revisions

no edit summary
No edit summary
Line 1,135:
The smallest number whose square ends in 269696 is: 25264
Its square is: 638269696</pre>
 
===Wrapper===
 
====Note====
 
{{quote
| <i>Write code that Babbage himself would have been able to read and understand.</i>}}
 
Charles Babbage is familiar with symbol manipulation and low level programming.
 
==== Program ====
 
<syntaxhighlight lang=lisp>;;;; Ver. 2023-02-18
 
(load "blackbox.lisp")
 
;;; Jan Łukasiewicz notation (1924) is a mathematical notation in
;;; which operators precede their operands. n mod 1000000 = 269696
;;; ⇒ n = k * 1000000 + 269696 where n and k are natural numbers.
 
(∇ ANSWER
(← N 520)
STEP (← S (* N N))
(→ (= (MOD S 1000000) 269696) (▷ HALT))
(← N (+ N 2))
(▷ STEP)
HALT (⍝ N))</syntaxhighlight>
 
==== Execution ====
 
<pre>(ANSWER)</pre>
 
{{out}}
<pre>25264</pre>
 
==== Black box ====
 
Lisp « jargon » is hidden in a black box.
 
<syntaxhighlight lang="lisp">(defmacro ∇ (name &body body)
`(defun ,name () (tagbody ,@body)))
(defmacro ▷ (label)
`(go ,label))
(defmacro → (test &body body)
`(when ,test ,@body))
 
 
(defmacro ← (place value)
`(if (boundp ',place)
(setf ,place ,value)
(defvar ,place ,value)))
 
(defmacro ⍝ (object)
`(print ,object))</syntaxhighlight>
 
==== References====
 
[https://journals.openedition.org/bibnum/pdf/542 Le premier article scientifique de l'histoire de l'informatique ?] ''François Rechenmann. OpenEdition Journals.''.
 
''cyril nocton (cyril.nocton@gmail.com) w/ google translate.''
 
=={{header|Component Pascal}}==
422

edits