Magic Number coding question---1.  A number is said to be a magic number, if summing the digits of the number and then recursively repeating this process for the given sum untill the number becomes a single digit number equal to 1. Example:     Number = 50113 => 5+0+1+1+3=10 => 1+0=1 [This is a Magic Number]     Number = 1234 => 1+2+3+4=10 => 1+0=1 [This is a Magic Number]     Number = 199 => 1+9+9=19 => 1+9=10 => 1+0=1 [This is a Magic Number]     Number = 111 => 1+1+1=3 [This is NOT a Magic Number].

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 10PE
icon
Related questions
Question

Magic Number coding question---1. 
A number is said to be a magic number,
if summing the digits of the number and then recursively repeating this process for the given sum
untill the number becomes a single digit number equal to 1.

Example:
    Number = 50113 => 5+0+1+1+3=10 => 1+0=1 [This is a Magic Number]
    Number = 1234 => 1+2+3+4=10 => 1+0=1 [This is a Magic Number]
    Number = 199 => 1+9+9=19 => 1+9=10 => 1+0=1 [This is a Magic Number]
    Number = 111 => 1+1+1=3 [This is NOT a Magic Number].

 

Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Declaring and Defining the Function
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning