The sigma function computes the sum of integers from 1 to num:

N * (N+1) / 2

Write a program to compute sigma, implementing three functions that use different methods for computation. The first function (formulaSigma) will use the formula:

SumOfInts = num * (num+1) / 2

to compute the sum of integers. NOTE: Integer division is used.

The second function (loopSigma) will compute the sum using iteration (i.e. a loop).

The third function (recursiveSigma) will compute the sum using recursion.

All three function should take num as an argument and return the sigma value.

The main function should first explain to the user what the program will do.

It should then prompt the user for a positive integer or zero (num) to exit, error check it is zero or greater.

If the user does not enter 0 for num, then call the formulaSigma, loopSigma and recurSigma functions, using num as the input parameter for each.

The results of all three function calls should be printed out with descriptive text. Note that the results should be the same!

Sample Run:

Program to compute sigma (sum of integers 1 to num)

Enter a positive integer or zero to exit: 5

Formula result = 15
Iterative result = 15
Recursive result = 15

The program should loop and continue to compute results for new values of num, until the user enters 0 for the value of num.

The only way the user may exit the program is to enter 0 for the value of num -- do not ask the user whether to run the program again.