Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
55
Task/Babbage-problem/Quackery/babbage-problem.quackery
Normal file
55
Task/Babbage-problem/Quackery/babbage-problem.quackery
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
( . . . . . . . . . . . . . . . . . . )
|
||||
|
||||
( The computer will ignore anything between parentheses, providing there is
|
||||
a space or carriage return on either side of each parenthesis. )
|
||||
|
||||
( . . . . . . . . . . . . . . . . . . )
|
||||
|
||||
( A number squared is that number, multiplied by itself.
|
||||
|
||||
Here, "dup" means "make a duplicate" and "*" means "multiply two numbers",
|
||||
So "dup *" means "make a duplicate of a number and multiply it by itself".
|
||||
We will tell the computer that this action is called "squared". )
|
||||
|
||||
|
||||
[ dup * ] is squared
|
||||
|
||||
|
||||
( "squared" takes a number and returns that number, squared. )
|
||||
|
||||
( . . . . . . . . . . . . . . . . . . )
|
||||
|
||||
( A number n ends with the digits 269696 if n mod 1000000 = 269696,
|
||||
When expressed in postfix notation this is: 1000000 mod 269696 =
|
||||
We will tell the computer that this test is called "ends.with.269696". )
|
||||
|
||||
|
||||
[ 1000000 mod 269696 = ] is ends.with.269696
|
||||
|
||||
|
||||
( "ends.with.269696" takes a number and returns true if it ends with 269696,
|
||||
and false if it does not. )
|
||||
|
||||
( . . . . . . . . . . . . . . . . . . )
|
||||
|
||||
( The square root of 269696 is approximately equal to 518.35, so we need not
|
||||
consider numbers less than 519.
|
||||
|
||||
Starting withe 518, we will intruct the computer to repeatedly add 2 to
|
||||
the number using the command "2 +" (because the number we are looking for
|
||||
must be an even number as the square root of any even perfect square
|
||||
must be an even number), then square a duplicate of the number until a
|
||||
value is found of which its square ends with 269696.
|
||||
|
||||
"until" will take the truth value returned by "ends.with.269696" and, if
|
||||
that value is "false", will cause the previous commands from the nearest
|
||||
"[" preceding "until" to be repeated.
|
||||
|
||||
When the value is "true" the computer will proceed to the word "echo",
|
||||
which will take the calculated solution and display it on the screen. )
|
||||
|
||||
|
||||
518 [ 2 + dup squared ends.with.269696 until ] echo
|
||||
|
||||
|
||||
( . . . . . . . . . . . . . . . . . . )
|
||||
Loading…
Add table
Add a link
Reference in a new issue