Uploaded by lucasli7747

Kenneth Algorithm

advertisement
1.
A.) Start with a guess for the square root, x0. We can choose x0 = n/2.
Compute x1 = (x0 + n/x0)/2.
If x1 is close enough to x0 then we can stop and return x1 as the result. Otherwise, we
can set x0 = x1 and go back to the previous step
It is possible to compute the square root of a positive integer n by beginning with a
guess for the square root, which is denoted by x0. We can go with x0 = n/2 as our
option. After that, you compute x1 as the following: x1 = (x0 + n/x0)/2. If the distance
between x1 and x0 is small enough (for instance, if the difference between them is less
than 0.001), then we can call x1 the outcome. We can simply reset x0 to equal x1 and
continue the process.
B.)
Set x0 = n/2.
Set x1 = (x0 + n/x0)/2.
If the difference between x1 and x0 is less than 0.001, return x1.
Otherwise, set x0 = x1 and go back to step 2.
Algorithm begins by making a best guess for the value of x0, which is the square root.
Then, it takes the average of x0 and n/x0 to come up with a new guess called x1, which
it computes. If this new guess is sufficiently similar to the one that came before it, then
we will use that one as the result. If this is not the case, we will set x0 to equal x1 and
continue the operation
2.
A).
Euclid 2 ( Mn )
algorithm
data
substations rather
uses
integer
than
)
Algorithm Euclid ( Mn
compute god Cnn )
Input
:
nonnegative
The
greatest
while
it
by
Two
output !
code !
based
Euclid algorithm
n
do
-1-0
man
m
return
snap
←
M
m
integers
common
Chin )
-
n
Mand
n
divisor of
on
both
m
divisions
substations
edval
and
n
to
0
B).
Euclid's definition : It is an algorithm for computing the Greatest Common Divisor (GCD)
of two integers ( numbers) , the largest number that divides them both without a
reminder.
board
of
to
difficult
Too
algorithm
Euclid 's
Earnt
to
god ( m,n )
which
The
includes
total
to
3
.
do
7-
Cnet
This
we
Prove
"
=
ntn
(1+4)
n
for
,
? 3
to
(1+1)
reanimate
"
and
the
of
initial
moves
first
:
it
it
version
.
maximum
of
subtraction
is
is
the
initial numbers
pair
80km ,n )
odd
is
go
them
the
on
even
,
-
one
2
should
choose
n±
equivalent
is
the
the
written
.
equivalent
is
En )
to
)n÷
is
which
to
by
only
possible
,%Tmn ,
to prove
want
we
is
of
choose
second
m
integers
two
it
should
One
where
number
3. Hence
•
and
be
can
go.%ca.mg
to
enrol
is
integers
that
prove
integers generated
the
are
generated
integers
at
Total number
to
"
decreasing
ntn
>
it
N
Cut
is
.
""
)
≥ ( ntl
("÷j
we
1) ¥
"
≤N
first prove
we
dressing
get
that
the
function
(
It
±)
"
<
n
statement
when
4.
pcn )
let
the
Two
If
If
Since
By
the
is
second
Ln -4
definition
know
as
such
n -11
where
Tw , by
not
statement
first
we
pal , pls)
the
itself
is
n -11
f-*
terms
,
.
the
in
.
.
.
statement
n
as
sequence
be true
,
Platt )
for
valid
is
expressed
be
Fibonacci
Pcn ) to
.
can
cases :
ntl
.
.
that
show
we
2)
that
assume
that
statement
the
distinct
of
sum
we
1)
he
,
that
Fibonacci number
a
true
is
statement
we
Cnn
,
Fibonacci number
a
Pln
-4
true
is
Fk ) Ln -4
-
we
decompose
may
-
then
,
)
Fx
so
is
done
are
then
ntl
by
true
into
the
.
FKLH
Fiat Ch -11
inductive
hence
it
:
-
Fk
the
Fi
-
,
+
Fir
+
subscripts
strong
induction
.
an
are
,
.
-1
-11 < Fk -11
may
Fk )
-
Pln ) holds
be
,
for all
n
≥
.
hypothesis
Fim
distinct
.
1
,
expressed
Download