Python Foundation Classroom Notes – 19/08/2021

Problem Solving

  • Problem Refer Here

    • Lets solve this problem by breaking into two sections
      • Find all the factors
      number = 13195
      index = 2
      until index < number 
          if number%index == 0 then
             print index
          index = index + 1
      
      • Find if the number is prime or number
      function find_prime:
      number = 29
      
      index = 2
      until index < number
          if number%index == 0 then
             say not prime
             stop
          index = index + 1
      
      say number is prime
      
      • Lets find the largest factor of number
      number = 100
      
      index = number - 1
      until index > 1
          if number%index == 0:
            print index is largest factor
            stop
          index = index - 1
      
      • Lets find the largest prime factor
      number = 13195
      index = number - 1
      until index > 1
          if number%index == 0 then
              if find_prime index == True
                  print index
          
          index = index - 1
      
      
  • Exercise: Problem: Try to find if a number is pallendrome or not

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About continuous learner

devops & cloud enthusiastic learner