Password Found For Numbers - Sharp MZ-80A Owner's Manual

Hide thumbs Also See for MZ-80A:
Table of Contents

Advertisement

36
|
Password Found for Numbers
The
greatest
common divisor (GCD) is
a
passward for
two
integers.
For example, presuming that
two
numbers
are
10 and
20, divisible numbers for 10 and
20
are
four numbers that
are 1,
2, 5 and 10.
Of these
numbers, the maximum
value, namely, 10 is the
greatest
common
divisor for numbers 10 and 20.
Now,
let's
generate a
program.
10
PRINT "X", "Y", -PASSWORD"
20 READ X, Y
>
--
-
30
PRINT
X.
Y
<C~
Comma
<
.
)
following Y is very convenient for continuous display
on the
40
Q
= INT (X/Y)
CRT screen.
50 R =
X
-
Q
*
Y
60 X = Y
:
Y
=
R
70 IF
R
>
0 THEN
40
80
PRINT X
:
GOTO 20
90
DATA 63.99, 1221,
121,64.658
100
DATA
12345678.987654321
110
END
RUN
Exposure of
a
Trick for this Program !
Long ago,
a
Greek mathematician, Euclid,
developed this method
of
solution.
Using IF
.....
try
as many as
possible.
10 IF SGN (X)
=
-1 THEN ?
-MINUS"
20 IF SGN (X) = 0
THEN ? "ZERO"
30 IF SGN (X) = 1
THEN ? "PLUS"

Advertisement

Table of Contents
loading

Table of Contents