Python Foundation Classroom Series – 18/Aug/2021

Foundations continued

Problem Solving

max = 1000
index = 1
sum = 0
until index < max do # looping
    if index%3 == 0 or index%5 == 0 then # conditional statement
        sum = sum + index
    index = index + 1

print sum
a = 1
b = 1
c = 0
sum = 0
until c < 4000000 
    c = a + b
    if c%2 == 0 then
       sum = sum + c
    a = b
    b = c

Leave a Comment

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

About learningthoughtsadmin