Question: Pages in a Book: Write a program that prompts the user to enter a positive integer m that represents the sum of all page numbers
Pages in a Book: Write a program that prompts the user to enter a positive integer m that represents the sum of all page numbers in a book. The program prints whether the number is a valid sum or not. For example, the integer 21 is a valid sum of page numbers because 1 + 2 + 3 +4 +5 +6 = 21. The integer 25 is not a valid sum because the sum of the first 6 page numbers is 21 and the next page number is 7, so the sum of the first 7 page numbers should be 28. If m is a valid sum of all page numbers, then there must be an integer n such that 1+2+3+ ... +n=n (n+1)/2 = m Sample inputs / outputs: Enter the sum of pages: 4005 4005 is a valid sum of page numbers 12
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
