Intro_to_Problem_Solving_
Intro_to_Problem_Solving_
omansh.mathur_1
scaler.com
23 is a prime
Is 1
prime
Factors 2 1
if L na
count te
y
if I count 2
return true
else
return fals
y Iterations
Ef I 21
it A count I
2 2
5 3 Count 2
6
7 Count 3
E 21 Count 4
23 count
Eg2 I I
2
E 23
Eg3 n I
amiii
s.se
109
If
n 10 see
204108
I see 108
10 see 109
1018
if
n 10 see
317
yes
Qbs If a b N then
the pair La May
both are
factors
b Nla
N 24
i Nti
I I
Da 60
4 6 Man a 60
__f 4
I 2 2
24
is no Y
N
Inman inhg
i In
if C n t I o
L if Citi n
counts I
co I l
else
count 2
3
y n g
41 3,9
if C count 2
election true
else
return false
y Iterations TN
n 36
count
I I 2
2 9
3 6
4 8
5 8
6 9
N 23
Count
i 2
2
3
III
carerminfant
S I 2 3 e 99 t 100
25 1 01 X 100
I C
S 5050
1014101
S It 2 3 t th
25 n nee
s
Nzd
many
ammann
times
you can divide
by 2 till it reaches 1
integer division
Centeg s
712 3
20 I O
21 2 A 1
2 9 22 2 1 2
23 8 24 2271 3
416 78 24 22 22 4
8E 72 IEF iu z.to
51 725 312 26 53 21 5
60 730 2154743 21 5
323332 51 60
631
n a y
y is called the logarithm
of n
log n y
log 64 6
dog 51 5
int L int
log n
L int count 0
while Cn D
a
n 2 2
count te
y
return count
y
2 64
3 2 I
3
I 6 2
8 3
4 4
2 5
1 6
50
25 1
12 2
6 3
3 4
I 5
Break Back at 10 35
Emazon
Given perfect square no
a
Eg 25 7 5
Et
4g 7
N is perfect means
square
that an integer n exists at
2 22 N
E if Citi n
return i
Y
y
2 36 5 1
E 2
3
E 4
5 5
It
Number of iterations JN
Binary search
Qt If n increases the
Squaleroot also
increases
625
1 15 7 3 3 625
A 4 9
start end
mid 21 25
62 313
mid 4 157
321
2
79
527
79 79 7 625
40
121
40 440 7 625
1 20 1 40
421
20 20 C 625
2040
20 40
C
IF 30
30 30 7625
20 30
20 25
320
25 25 625
1 625 625
I 313 3 3
I 252 IÉ
I 79 78
I n
J n nos
n The
s e J
s e
u
x x
72
Number of iterations
search
in binary
login
n 1018
108 60
dog
07018 109
end stare
while l starts end
108 I
7
10 20 10
11,08
on n
Kase n
logins D
n