given big number should be added one after another until it sum of output reach less than 10.
input say 456789
i should manipulate in code like
1.4+5+6+7+8+9=39
2.check 39<10 if not again 3+9=11
3.check 11<10 if not again 1+1=2
4.check 2<10 if yes
I can guess i should right a recursive function.
but i done have an idea to how to break an individual integer into pieces.
You can use iterative function too. Recursion is not mandatory here.
but i done have an idea to how to break an individual integer into pieces.
There are two ways:
1) convert integer to string, and treat each character as integer.
2) Find number modulo 10, this is last digit. Divide (with integer division) number by 10, this will remove last digit from number. Repeat while number is not 0.
BUT, as a mathematician I cannot miss an opportunity to apply some interesting properties of sum of sum ... of digits: it is equal to ((number - 1) % 9) + 1.
Convert integer to string we can do. also we can store it in string array.
Using iteration is it possible to sum charecter..?? it will not throw syntax error.??
//2) Find number modulo 10, this is last digit. Divide (with integer division) number by 10, this will remove last digit from number. Repeat while number is not 0.//
No i want to add individual digits only.
anyhow thanks for your other info how it can be handled mathemetically.