![chuky1325](/avatars/25922.jpg)
chuky1325
22.04.2020 •
Computers and Technology
The sum of the numbers 1 to n can be calculated recursively as follows: The sum from 1 to 1 is 1. The sum from 1 to n is n more than the sum from 1 to n-1 Write a function named sum that accepts a variable containing an integer value as its parameter and returns the sum of the numbers from 1 to to the parameter (calculated recursively).
Solved
Show answers
More tips
- F Food and Cooking 10 Ideas for a Wedding Anniversary Gift...
- H Health and Medicine Hangover: How to Get Rid of It Quickly?...
- S Style and Beauty How to Choose the Right Fur Coat and Avoid Regrets?...
- C Computers and Internet How to Create a Folder on Your iPhone?...
- G Goods and services How to sew a ribbon: Tips for beginners...
- F Food and Cooking How to Make Mayonnaise at Home? Secrets of Homemade Mayonnaise...
- C Computers and Internet Which Phone is Best for Internet Surfing?...
- F Food and Cooking Everything You Need to Know About Pasta...
- C Computers and Internet How to Choose a Monitor?...
- H Horoscopes, Magic, Divination Where Did Tarot Cards Come From?...
Answers on questions: Computers and Technology
- C Computers and Technology Create a python code with 5 circles, 5 polygons, 5 line commands, 2 for loops, and 1 global variable...
- B Business John owns a second home in palm springs, ca. during the year, he rented the house for $4,000 for 36 days and used the house for 14 days during the summer. the house remained...
- B Biology Please complete this!! giving brainliest :)...
- M Mathematics Randy is walking home from school. According to the diagram above, what is his total distance from school to home? Show your work and include units. If he had a jet pack,...
- E English What is the significance of the dance the tribe performs for smith?...
Ответ:
See explaination
Explanation:
The code
#function named sum that accepts a variable
#containing an integer value as its parameter
#returns the sum of the numbers from 1 to to the parameter
def sum(n):
if n == 0:
return 0
else:
#call the function recursively
return n + sum(n - 1)
#Test to find the sum()
#function with parameter 5.
print(sum(5))
Ответ:
766 1928 8695
iL0ixR
Explanation: