#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Jan 25 14:48:04 2022 @author: richardson """ import time # making a function def funSum(a,b): #This function adds multiples of 5 from a through b somesum = 0 j=a #starting value of j while j<=b: #this continues as long as j<=b if b>10000: break #breaks out of loop if b>10000 if j%5==0 and b<=10000: somesum +=j #adds j if it is a multiple of 5 j+=1 #adds 1 to j if b>10000: #returns 0 and quits the program if b>10000 return 0 return somesum # our answer t1=time.time() print(funSum(50,100)) print(funSum(24,7589423)) t2=time.time() print("time ellapsed = "+str(t2-t1)) #The above checks how quickly the code runs def funSum2(a,b): #does everything in 1 line return sum([j for j in range(a,b+1) if j%5==0 and b<=10000]) t1=time.time() print(funSum2(50,100)) print(funSum2(24,7589423)) t2=time.time() print("time ellapsed = "+str(t2-t1))