Recursive Functions for Factorial and Power Calculations, Lecture notes of Computer Programming

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

2012/2013

Uploaded on 04/27/2013

kid
kid 🇮🇳

4.3

(18)

110 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
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*1
Question 2
Write a complete program to calculate the power using recursive function
power(base, exponent) that, when invoked, returns
pf2

Partial preview of the text

Download Recursive Functions for Factorial and Power Calculations and more Lecture notes Computer Programming in PDF only on Docsity!

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