Python Classroom notes 15/Feb/2026

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

Preview

By continuous learner

enthusiastic technology learner

Leave a Reply

Discover more from Direct AI Powered By Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading