Magic Number

Suraj Ghimire
37 Posts

WAP to check if a number is magic number.

A number is called magic number if adding all the digit in every pass, will ultimately give you 1.

Eg: N= 1234

Pass 1:   1+2+3+4 = 10

Pass 2:   1+0 = 1(Over) Magic Number

 

Eg: N= 1891

Pass 1: 1+8+9+1 = 19

Pass 2: 1+9 =10

Pass 3: 1+0 = 1(Over) Magic Number  

 

 

Published By : Suraj Ghimire
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

Comments