Math induction with c++

Hi, I am working on a program for a school assignment. I am not sure exactly how to code this at all. If anyone could help, that would be very much appreciated. This is the problem:

1+2+3+...+n=(n(n+1))/2

Write a C++ program that compares the execution time of the above summation using two different solutions: one that uses loops, and another that uses the closed form approach. Use large values of n for the comparisons, such as, 10^7, 10^8, 10^9, 10^10, 10^11,10^12, 10^13, and 10^14. Provide a comparison table for the execution time in both solutions.Do not worry about the value of the actual sum. Overflow will occur in the sum value rendering it invalid; however, this is not the primary concern of the program. Execution time is the primary concern.


Thank you for your help
here you've got an example of how to measure time http://www.cplusplus.com/reference/chrono/steady_clock/
Topic archived. No new replies allowed.