Question: Write a function that takes an argument n and returns the sum of integers from 1 to n . For example, if n = 5
Write a function that takes an argument and returns the sum of integers from to For example, if your function should add up and return If is less than just return Use a while loop to calculate this sum.
def sumofintegers :
if :
return
sum
while :
sum sum
return sum
printsumofintegers # should print
printsumofintegers # should print
printsumofintegers # should print
Reset
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
