Question: Question 4 Write a function that takes an argument n and returns the sum of integers from 1 to n . For example, if n
Question
Write a function that takes an argument n and returns the sum of integers from to n For example, if n your function should add up and return If n is less than just return Use a while loop to calculate this sum. def sumofintegersn:
if n :
return
if n :
return
i
sum
while number :
sum sum i
i
return sum
printsumofintegers # should print
printsumofintegers # should print
printsumofintegers # should print
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
