# A)Write a Python function product(a, b) that recursively computes an

Content type
User Generated
Rating
Showing Page:
1/6
a)Write a Python function product(a, b) that recursively
computes and returns the value of a times b. Use only the
addition operator, and do not use any loops. You can
assume that both parameters are non-negative integers.
b)Use induction to prove that your algorithm from the
previous part is correct
Solution
Recursion has something to do with infinity. I know
recursion has something to do with infinity. I think I know
recursion has something to do with infinity. He is sure I
think I know recursion has something to do with infinity.
We doubt he is sure I think ... We think, we convinced you
now, that we can go on forever with this example of a
recursion from natural language. Recursion is not only a
fundamental feature of natural language, but of the human
cognitive capacity. Our way of thinking is based on
recursive thinking processes. Even with a very simple
grammar, like \"An English sentence contains a subject
and a predicate. A predicate contains a verb, an object and
a complement\", we can demonstrate the infinite
possibilities of the natural language. Stephen Pinker

Showing Page:
2/6
phrases it like this: \"With a few thousand nouns that can
fill the subject slot and a few thousand verbs that can fill
the predicate slot, one already has several million ways to
open a sentence. The possible combinations quickly
multiply out to unimaginably large numbers. Indeed, the
repertoire of sentences is theoretically infinite, because
the rules of language use a trick called recursion. A
recursive rule allows a phrase to contain an example of
itself, as in She thinks that he thinks that they think that he
knows and so on, ad infinitum. And if the number of
sentences is infinite, the number of possible thoughts and
intentions is infinite too, because virtually every sentence
expresses a different thought or intention.\"1
We have to stop our short excursion to recursion in
natural languages to come back to recursion in computer
science and finally to recursion in the programming
language Python.
The adjective \"recursive\" originates from the Latin verb
\"recurrere\", which means \"to run back\". And this is what
a recursive definition or a recursive function does: It is
\"running back\" or returning to itself. Most people who
have done some mathematics, computer science or read a
book about programming will have encountered the

Showing Page:
3/6

End of Preview - Want to read all 6 pages?
Access Now
Unformatted Attachment Preview
a)Write a Python function product(a, b) that recursively computes and returns the value of a times b. Use only the addition operator, and do not use any loops. You can assume that both parameters are non -negative integers. b)Use induction to prove that your algorithm from the previous part is correct Solution Recursion has something to do with infinity. I know recursion has something to do with infinity. I think I know recursion has something to do with infinity. He is sure I think I know recursion has something to do with infinity. We doubt he is sure I think ... We think, we convinced you now, that we can go on forever with this example of a recursion from natural language. Recursion is not only a fundamental feature of natural language, but o f the human cognitive capacity. Our way of thinking is based on recursive thinking processes. Even with a very simple grammar, like \"An English sentence contains a subject and a predicate. A predicate contains a verb, an object and a complement\", we can demonstrate the infinite possibilities of the natural language. Stephen Pinker phrases it like this: \"With a few thousand nouns that can fill the subject slot and a few thousand verbs that can fill the predicate slot, one already has several million ways to open a sentence. The possible combinations quickly multiply out to unimaginably large numbers. Indeed, the repertoire of sentences is theoretically infinite, because the rules of language use a trick called recursion. A recu ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

### Review

Anonymous
Excellent resource! Really helped me get the gist of things.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4