add a double digit number together

  • Thread starter adding double digit numbers
  • Start date
A

adding double digit numbers

in one box I end up with a double digit number. I was these two numbers in
the double digit number to be added together and reduced till only one number
remains. I think it has something to do with integar numbers?
 
T

T. Valko

A1 = 37

=SUM(--MID(A1,{1,2},1))

returns 10 (3+7)

You'll need to explain in more detail what you mean by: reduced till only
one number remains.

--
Biff
Microsoft Excel MVP


"adding double digit numbers" <adding double digit
[email protected]> wrote in message
news:[email protected]...
 
R

Rick Rothstein

If you want to do it with text functions, this seems like a simpler method to me...

=LEFT(H16)+RIGHT(H16)
 
R

Rick Rothstein

When you say "reduced till only one number remains", did you mean add the digits together and if that addition resulted in a 2-digit number, add them together and keep doing that until only a single *digit* remains? If so, use this...

=MOD(A1,9)+9*(MOD(A1,9)=0)

which will work on any number, not only 2-digit numbers.
 
T

T. Valko

this seems like a simpler method to me...

Yeah, me too!


--
Biff
Microsoft Excel MVP


If you want to do it with text functions, this seems like a simpler method
to me...

=LEFT(H16)+RIGHT(H16)
 
D

Dana DeLouis

till only one number remains.

From Number Theory on 9's...

=MOD(A1-1,9)+1

- - -
HTH :>)
Dana DeLouis
 
R

Roger Govier

very nice, Dana
One small caveat, the number needs to be greater than 0.
0 or null return 9
=IF(A1<1,"",=MOD(A1-1,9)+1)
 
R

Rick Rothstein

A couple of things. First, you accidentally left the equal sign in front of
the MOD function when you modified Dana's formula. Second, I agree that 0
should not return 9, but I don't think the empty string is correct either...
I would return 0 for 0. If negative numbers do not need to be considered,
then this...

=IF(A1="","",IF(A1=0,0,MOD(A1-1,9)+1))

And if negative numbers do need to be considered, something like this
maybe...

=IF(OR(A1<0,A1=""),"",IF(A1=0,0,MOD(A1-1,9)+1))

Another possibility, if negative numbers need to be considered, is to return
the sum of the digits without regard to the sign...

=IF(A1="","",IF(A1=0,0,MOD(ABS(A1)-1,9)+1))

or, do the above, but return the sign with it (which will save us the test
for 0)...

=IF(A1="","",SIGN(A1)*(MOD(ABS(A1)-1,9)+1))
 
R

Roger Govier

Hi Rick
A couple of things. First, you accidentally left the equal sign in front
of the MOD function when you modified Dana's formula.

Yes, my bad.
Thanks for picking it up.
 
S

shg

MOD(A5-1,9) returns an error for N >= 1,207,959,553.

You can use instead =A1 - FLOOR(A1 - 1, 9
 
D

Dana DeLouis

Hi. Just in case that limit was done by trial-n-error, Microsoft admits
the error will occur like you said at:

9*2^27

1207959552

I really wish they would fix it.

Not related to the op's question, but as a side note, people have posted
a lot of programs to test if a number
is prime. I just added one more test to my number-theory routines based
on that article...

n = 98789987654343

Is this number prime?

DigitalRoot(n)

9

Hence, the number can not be Prime, and no further testing is necessary.

= = =
Dana DeLouis
 
Top