

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Two recursive functions for calculating factorials and powers. The first function, factorial(number), calculates the factorial of a given number from 100! to 1000!. The second function, power(base, exponent), calculates the power of a base number raised to an exponent. Both functions use recursion to perform the calculations.
Typology: Lecture notes
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Question 1 Write a complete program to calculate the factorials from 100! to 1000! using recursive function factorial(number) that, when invoked, returns number! =number(number-1) ….2 Question 2 Write a complete program to calculate the power using recursive function power(base, exponent) that, when invoked, returns
base exponent For example, power(3, 4) = 3333. Assume that exponent is an integer greater than or equal to 1. Hint: base exponent = base base exponent- and the terminating condition occurs when exponent is equal to 1 because base 1 = base