Sums of the Natural, Odd, and Even Numbers up to N
EasyRead an integer N and print three lines: sum of natural numbers = 55, sum of odd numbers = 25, sum of even numbers = 30, where the three values are the sums of 1 to N, of the odd numbers in that range, and of the even numbers in that range. Use one for loop from 1 to N with three long accumulators. N must be between 1 and 60000 so that the sums fit in a 32-bit long; otherwise print N must be between 1 and 60000 and return 1. If N cannot be read, print invalid input and return 1.
Success Criteria
Your code must pass 7 test case(s) to complete this exercise. 3 hint(s) are available if you need help.
Sign in to track your progress
You can work on exercises as a guest, but sign in to track your progress and save your submissions.
How did you find this exercise?
Your rating helps us improve the content.