Re: Adding digits together



The original poster never did mention if he needed to keep going...

....and the mod 9 answer is quite limited in the scope. It will not handle
the case where he does not want to keep going, and it will not reveal the
intermediate values, should those be desired.

I might also mention, the example from Brian Dunning was taking multiple
values and reducing them to one, not taking one value and expanding it to
multiple iterations -- which is a far more difficult problem. For example:

987987987987987987987
168
15
6

Is three iterations. This cannot be produced by the particular method
Dunning used.

However, we're in luck! For there to be more than three iterations, the
source number would have to exceed

999,999,999,999,999,999,999,999,999,999,999,
999,999,999,999,999,999,999,999,999,999,999,
999,999,999,999,999,999,999,999,999,999,999,
999,999,999,999

....In other words, 1e+111 or greater!

If this is really what is desired then simply duplicating the field a couple
times (SumN based on N; SumSumN based on SumN; SumSumSumN based on SumSumN,
and if truly necessary, SumSumSumSumN based on SumSumSumN) should be much
more pleasant an exercise than designing the proper recursion.

Bill :)

"42" <nospam@xxxxxxxxxx> wrote in message
news:MPG.1dd5d80f300d9e11989da9@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
> In article <LImdnVKtRZ1sqPHenZ2dnUVZ_tKdnZ2d@xxxxxxxxxxx>, wjm@xxxxxxx
> says...
>> The sum of digits is used in a variety of mathematical proofs, theorems,
>> and
>> games. For example, to determine is a number is divisible by 9. When you
>> have some spare time, do a Google search on "sum of digits" for some
>> interesting exercises.
>>
>> The hard part of the problem seems to be the idea that there could be an
>> arbitrary number of digits in the source number. This leads many to think
>> that FileMaker Developer, a recursive function or some kind of script is
>> required. Such is not the case.
>>
>> Given n, a text field, containing an integer with an arbitrary number of
>> digits
>>
>> Evaluate (
>> Substitute (n;
>> ["0";"0+"];
>> ["1";"1+"];
>> ["2";"2+"];
>> ["3";"3+"];
>> ["4";"4+"];
>> ["5";"5+"];
>> ["6";"6+"];
>> ["7";"7+"];
>> ["8";"8+"];
>> ["9";"9+"]) & "0")
>>
>> Will return the sum of those digits.
>>
>> Enjoy,
>>
>> Bill
>
> Cool solution, Bill.
>
> Although I think the notion of recusion wasn't on an arbitrary number of
> digits, it was on the idea that you might have to perform the addition
> an arbitrary number of times until you just had one digit. (although the
> mod9 solution dodges that)
>
> -regards,
> Dave


.



Relevant Pages

  • Re: Convergance checking of log
    ... really takes some hundreds of iterations to converge. ... After every iteration you will have 6 times as many correct digits. ... It's probably not a great way to compute logarithms, ... converging series" I think it will be hard to beat. ...
    (sci.math)
  • Re: HHC 2011 videos
    ... of computers, iterative tasks can be carried out, e.g. lengthly ... simulations - and it is during those iterations that the number of ... available digits becomes important. ... are many ARM opcodes which which would require several Saturn ...
    (comp.sys.hp48)
  • Re: "Elementary" number theory problem
    ... > I am working thru some notes on Elem. ... and l the number obtained by putting the digits in increasing ... > Each number goes thru 12 iterations. ... mapped to itself by the stated operation since 7641-1467=6174] ...
    (sci.math)
  • Re: division problem
    ... lot faster than emulating hardware. ... The IBM Jikes Compiler has a 64 bit number class for 32 bit machines. ... then use the approximation given (it will be good to about 15 digits on ... 60 digits, three iterations 120 digits, etc. ...
    (comp.lang.c)