In VBA excel: write a recursive function that computes the sum of the integers 1
ID: 3688348 • Letter: I
Question
In VBA excel: write a recursive function that computes the sum of the integers 1,2,3...n . Specify the argument as n. 12.4.1 Hands-on Exercise: Nonrec In this exercise, we will deve pute factorials Exercise: Nonrecursive and Recursive Factorial Functions be expressed concisely inthis ekercike. we will develop both e will develop both nonrecursive 2 Start Excel and enter the following information on Sep1 Start Excel and e and recursive functions to com- ng information on Sheetl: 1 Recursive Factorial Function n! (nonrecursive) nl (recursive 10 12 13 14 15 10 Step 2 First, let's develop a function that implements factorials without recursion Go to the VBE, insert a module, and type in the following code: Function Factorial (n) Dim i As Integer Factorial1 For i 1 To n Factorial Factorial 1 Next i End Function Suppose that n 3. Before the loop is entered.ractorial s initialized to 1 For the first iteration of the loop ( 1),Factorial is computed as Factorial 11 1 On the second iteration (i2 Factoria1-1 2 2 On the final iteration (i 3). At this point, the loop terminates, and the function returns the correct value for 3! = 1 x 2 × 3 6. Notice that for 0, the loop would never execute, and the correct factorial of 0·s| is returned. Factorial 2 * 3 6Explanation / Answer
0
1*0=0
2*1=2
3*2*1=6
4*3*2*1=24
5*4*3*2*1=120
6*5*4*3*2*1=720
7*6*5*4*3*2*1=5040
8*7*6*5*4*3*2*1=40320
9*8*7*6*5*4*3*2*1=362880
10*9*8*7*6*5*4*3*2*1=3628800
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.