Project 9: The digital root of a positive integer is found by summing the digits of the integer. If the result value is a single digit then that digit is the digital root. If the resulting value contains two or me digits, those digits are summed and the process is repeated. This is continued as long as necessary obtain a single digit. For example, consider the positive integer 24. Adding the 2 and the 4 yield: value of 6. Since 6 is a single digit, 6 is the digital root of 24. Now consider the positive integer Adding the 3 and the 9 yields 12. Since 12 is not a single digit, the process must be repeated. Add the 1 and the 2 yields 3, a single digit and also the digital root of 39. File: Input The input file will contain a list of positive integers, one per line. The end of the input will indicated by an integer value of zero. Output File: For each integer in the input, output its digital root on a separate line of the output. Example Input: 24 39 34527689425676154283672531207341 0 Example Output: 6 3

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
subject introduction to programming
it must be ((cc+ language))
Project 9:
The digital root of a positive integer is found by summing the digits of the integer. If the resultin
value is a single digit then that digit is the digital root. If the resulting value contains two or mom
digits, those digits are summed and the process is repeated. This is continued as long as necessary t
obtain a single digit. For example, consider the positive integer 24. Adding the 2 and the 4 yields
value of 6. Since 6 is a single digit, 6 is the digital root of 24. Now consider the positive integer 39
Adding the 3 and the 9 yields 12. Since 12 is not a single digit, the process must be repeated. Addins
the 1 and the 2 yields 3, a single digit and also the digital root of 39.
Input File:
The input file will contain a list of positive integers, one per line. The end of the input will be
indicated by an integer value of zero.
Output File:
For each integer in the input, output its digital root on a separate line of the output.
Example Input:
24
39
34527689425676154283672531207341
0
Example Output:
6
3
3
Transcribed Image Text:subject introduction to programming it must be ((cc+ language)) Project 9: The digital root of a positive integer is found by summing the digits of the integer. If the resultin value is a single digit then that digit is the digital root. If the resulting value contains two or mom digits, those digits are summed and the process is repeated. This is continued as long as necessary t obtain a single digit. For example, consider the positive integer 24. Adding the 2 and the 4 yields value of 6. Since 6 is a single digit, 6 is the digital root of 24. Now consider the positive integer 39 Adding the 3 and the 9 yields 12. Since 12 is not a single digit, the process must be repeated. Addins the 1 and the 2 yields 3, a single digit and also the digital root of 39. Input File: The input file will contain a list of positive integers, one per line. The end of the input will be indicated by an integer value of zero. Output File: For each integer in the input, output its digital root on a separate line of the output. Example Input: 24 39 34527689425676154283672531207341 0 Example Output: 6 3 3
Expert Solution
steps

Step by step

Solved in 4 steps with 5 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education