Problem: largest prime factor of 13,195
- Find largest factor of a number
number = 27
index = number // 2
result = 0
until index > 1
if number % index == 0 then
result = index
exit out of until
end if
index = index - 1
end until
say result
- To find largest prime factor
number = 27
index = number // 2
result = 0
until index > 1
if number % index == 0 then
# check if index is prime
is_prime = True
pindex = 2
until pindex <= index // 2
if index % pindex == 0 then
is_prime = False
exit out of until
end if
pindex = pindex + 1
end until
if is_prime == True then
result = index
exit out of until
end if
end if
index = index - 1
end until
say result
Important Concepts to understand for programming
