Posts

Showing posts from February, 2022

Multiples of 3 and 5

Problem: Find the sum of all the multiples of 3 or 5 below 1000. Solution: 1 2 3 4 5 sum = 0 for i in range ( 1000 ): if (i % 3 == 0 or i % 5 == 0 ): sum = sum + i print ( sum ) Note: This problem was taken from Project Euler (www.projecteuler.net). 

Simple Addition

Problem: Find the sum of two integers num1  and num2 . Python solution: 1 2 3 num1 = int ( input ()) num2 = int ( input ()) print (num1 + num2)