RosettaCodeData/Task/Babbage-problem/Bracmat/babbage-problem.bracmat

28 lines
1.2 KiB
Plaintext

(
500:?number {A child knows that 269696 is larger than 500*500,
but not by much. It is safe to start the search with 500.}
& whl {'whl' is shorthand for 'while'. It announces the evaluation of
an expression that is repeated until it fails.}
' ( @(!number*!number:~(? 269696)) { ~(? 269696) is a pattern. It says
that it will not match numbers that do
not end with the figures 269696.
The question mark is there to match all
the figures before 269696.}
& !number:<99736 { We should under no circumstance try
numbers that are larger than 99736.}
& 1+!number:?number { If the number did not pass the test,
we take the next number and repeat
the test. }
)
& out
$ ( str
$ ( "The smallest number that ends with the figures 269696 when squared is "
!number
", since the square of "
!number
" is "
!number*!number
)
)
)