Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
17
Task/Babbage-problem/BBC-BASIC/babbage-problem-1.basic
Normal file
17
Task/Babbage-problem/BBC-BASIC/babbage-problem-1.basic
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
REM Statements beginning 'REM' are explanatory remarks: the machine will ignore them.
|
||||
|
||||
REM We shall test positive integers from 1 upwards until we find one whose square ends in 269,696.
|
||||
|
||||
REM A number that ends in 269,696 is one that leaves a remainder of 269,696 when divided by a million.
|
||||
|
||||
REM So we are looking for a value of n that satisfies the condition 'n squared modulo 1,000,000 = 269,696', or 'n^2 MOD 1000000 = 269696' in the notation that the machine can accept.
|
||||
|
||||
LET n = 0
|
||||
|
||||
REPEAT
|
||||
LET n = n + 1
|
||||
UNTIL n^2 MOD 1000000 = 269696
|
||||
|
||||
PRINT "The smallest number whose square ends in 269696 is" n
|
||||
|
||||
PRINT "Its square is" n^2
|
||||
25
Task/Babbage-problem/BBC-BASIC/babbage-problem-2.basic
Normal file
25
Task/Babbage-problem/BBC-BASIC/babbage-problem-2.basic
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
REM Lines that begin 'REM' are explanatory remarks addressed to the human reader.
|
||||
|
||||
REM The machine will ignore them.
|
||||
|
||||
LET n = 269696
|
||||
|
||||
REPEAT
|
||||
|
||||
LET n = n + 1000000
|
||||
|
||||
REM Find the next number that ends in 269,696.
|
||||
|
||||
REM The function SQR finds the square root.
|
||||
|
||||
LET root = SQR n
|
||||
|
||||
REM The function INT truncates a real number to an integer.
|
||||
|
||||
UNTIL root = INT root
|
||||
|
||||
REM If the square root is equal to its integer truncation, then it is an integer: so we have found our answer.
|
||||
|
||||
PRINT "The smallest number whose square ends in 269696 is" root
|
||||
|
||||
PRINT "Its square is" n
|
||||
Loading…
Add table
Add a link
Reference in a new issue