RaviWildcat
Board Regular
- Joined
- Jun 18, 2010
- Messages
- 132
- Office Version
- 365
- Platform
- Windows
- MacOS
My young nephew is learning about factoring. The principle is that any non - prime number can be broken down into a series of prime numbers. For example, 9 = 3 x 3. My given number (9) can be broken down to a product of prime numbers (3 x 3). 12, can be broken into 2x2x3 and so on.
I'm looking at it like this: (Let's say my given number is in cell d7
you see how I'm first checking mods with prime numbers (2,3,5) - first checking does mod 2 = 0 , then divideby 2, else if mod 3 = 0 then divide by 3 else if mod 5 = 0 then divide by 5 - if none of these things are true then enter ".." then repeat with the result until I get to ..
Any thoughts about referencing a lookup table? I'm thinking about populating a lookup table with a prime number in each column - first the formula checks mod in row 1 of the table (which is 2) then it checks mod in row 2 of the table (which is the next prime number etc.) etc.
That would save me from having a monster if formula!
(There are other approaches that are alternatively cleverer / more cumbersome. I suppose I could write a recursive function in VBA too though the real fun comes from formulas
Any thoughts?
I'm looking at it like this: (Let's say my given number is in cell d7
Given number | |||
40 | =IFERROR(IF(MOD(D7,2)=0,D7/2,IF((MOD(D7,3)=0),D7/3,IF((MOD(D7,5)=0),D7/5,".."))),"..") | =IFERROR(IF(MOD(E7,2)=0,E7/2,IF((MOD(E7,3)=0),E7/3,"..")),"..") | |
40 | 20 | 10 | 5 |
you see how I'm first checking mods with prime numbers (2,3,5) - first checking does mod 2 = 0 , then divideby 2, else if mod 3 = 0 then divide by 3 else if mod 5 = 0 then divide by 5 - if none of these things are true then enter ".." then repeat with the result until I get to ..
Any thoughts about referencing a lookup table? I'm thinking about populating a lookup table with a prime number in each column - first the formula checks mod in row 1 of the table (which is 2) then it checks mod in row 2 of the table (which is the next prime number etc.) etc.
That would save me from having a monster if formula!
(There are other approaches that are alternatively cleverer / more cumbersome. I suppose I could write a recursive function in VBA too though the real fun comes from formulas
Any thoughts?