
November 25th, 2013, 03:24 AM
#1
Reducing numbers to one digit (numerology related)
Can you come up with an algorithm for me?
If you don't know what numerology is, or how it works just forget it and see if you can solve this problem.
I want to reduce a multiple digit number to one digit by adding each digit together, then again, and again etc...until there is only one digit.
Examples of reduction method:
9999 (9+9+9+9=37 then 3+7=10 then 1+0=1)
8765 (8+7+6+5=26 then 2+6=8)
4444 (4+4+4+4=32 then 3+2=5)
3210 (3+2+1+0=6)
Also, I need to convert letters into numbers in a way that the numbers 19 correspond with AI, JR, and SZ (z ending on 8 of course). And I'm hoping there's a short way to program in VB other than A=1 B=2 so on....
Any help is appreciated thanks!

November 25th, 2013, 04:32 AM
#2
Re: Reducing numbers to one digit (numerology related)
Originally Posted by nlw92
I want to reduce a multiple digit number to one digit by adding each digit together, then again, and again etc...until there is only one digit.
Observe the pattern:
7 => 7
8 => 8
9 => 9
10 => 1
11 => 2
12 => 3
13 => 4
14 => 5
15 => 6
16 => 7
17 => 8
18 => 9
19 => 1
20 => 2
21 => 3
Does it remind of a modulo operation, with a small catch?
Originally Posted by nlw92
Also, I need to convert letters into numbers in a way that the numbers 19 correspond with AI, JR, and SZ (z ending on 8 of course). And I'm hoping there's a short way to program in VB other than A=1 B=2 so on....
Let's assume that you're using a character set where the letters of the English alphabet are contiguous in alphabetical order. You can therefore map the alphabet to an integer from 1 to 26. Next, figure out how you can map the numbers from 1 to 26 to the numbers 1 to 9, according to your desired scheme.

November 25th, 2013, 04:36 AM
#3
Re: Reducing numbers to one digit (numerology related)
Originally Posted by laserlight
Observe the pattern:
7 => 7
8 => 8
9 => 9
10 => 1
11 => 2
12 => 3
13 => 4
14 => 5
15 => 6
16 => 7
17 => 8
18 => 9
19 => 1
20 => 2
21 => 3
Does it remind of a modulo operation, with a small catch?
Let's assume that you're using a character set where the letters of the English alphabet are contiguous in alphabetical order. You can therefore map the alphabet to an integer from 1 to 26. Next, figure out how you can map the numbers from 1 to 26 to the numbers 1 to 9, according to your desired scheme.
I get the pattern, can't believe I didn't think of it. For the English alphabet I don't know what you mean by mapping. I'm just learning and not very advanced in programming yet, but I learn quick if you can explain it a little more in depth.

November 25th, 2013, 08:06 AM
#4
Re: Reducing numbers to one digit (numerology related)
Originally Posted by nlw92
I get the pattern, can't believe I didn't think of it.
Good to hear that.
Originally Posted by nlw92
For the English alphabet I don't know what you mean by mapping.
When you say "I'm hoping there's a short way to program in VB other than A=1 B=2 so on", the "A=1 B=2 so on" is a mapping from the letters to the corresponding numbers. In this case you're using what is called a lookup table, but the "short way to program" involves replacing the lookup table with a mathematical formula.
By the way, numerology usually refers to some system of deriving possibly mystical meaning from numbers, whereas you're looking for something more along the lines of number theory.

November 25th, 2013, 08:42 AM
#5
Re: Reducing numbers to one digit (numerology related)
Originally Posted by laserlight
Good to hear that.
When you say "I'm hoping there's a short way to program in VB other than A=1 B=2 so on", the "A=1 B=2 so on" is a mapping from the letters to the corresponding numbers. In this case you're using what is called a lookup table, but the "short way to program" involves replacing the lookup table with a mathematical formula.
By the way, numerology usually refers to some system of deriving possibly mystical meaning from numbers, whereas you're looking for something more along the lines of number theory.
It's definitely for numerology, I just didn't fully explain the end goal of the program because I figured the mystical meanings of each number would be irrelevant. I was completely lost when it came to calculating the digital root using code. I think I'm going to use the formula Dr(n)=1+((n1)mod 9). How do you express mod 9 in Visual basic code?

November 25th, 2013, 11:05 AM
#6
Re: Reducing numbers to one digit (numerology related)
How do you express mod 9 in Visual basic code?
By using the mod operator. See
http://msdn.microsoft.com/enus/libr...=vs.90%29.aspx
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only  not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums  and not via private messages!
C++17 Compiler: Microsoft VS2017 (15.7.3)

November 26th, 2013, 06:55 AM
#7
Re: Reducing numbers to one digit (numerology related)
the above is even part of an "oldschool" verification method for checking if your results for manually adding/subtracting/multiplying/dividing large numbers is correct.
suppose you have
A * B = C
where A, B and C are large multidigit numbers, and you want to verify your calculated C is correct.
You COULD do the entire calculation again and verify your result, OR
> reduce A to a single digit by adding digit values
do the same for B and C and do the same for reduced A * reduced B.
The point being: reduce( reduce(A) * reduce(B)) then this result should be equal to reduce(C).
(or performing the same operation on reduced operands, yields the reduced result).
example:
12345 * 6789 = 83810205
reduce 12345 = 6
reduce 6789 = 3
3*6 = 18 > reduce to 9
reduce 83810205 = 9 which is equal to the above.
So our result is 'probably' correct.
nowadays of course, you have calculators to do calculations like above
THe above works for add/subtract and divide also, there's a bit added complexity in division if there's a remainder.
Last edited by OReubens; November 26th, 2013 at 06:57 AM.
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules

Click Here to Expand Forum to Full Width
OnDemand Webinars (sponsored)
