Question: Task 1 : Write a program that asks the user to enter a positive integer N . The program then computes and prints the sum

Task 1: Write a program that asks the user to enter a positive integer N. The program then
computes and prints the sum of all numbers between 1 and N (inclusive).
a) Do this using standard (iterative) technique (a for loop and an accumulator variable)
b) Now repeat the same task, but this time by defining a recursive function summe(N).
Hint: The factorial example above should be a good starting point.
c) Try both solutions for a large number, say N=500

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!