Intel's Ronler Acres Plant

Silicon Forest
If the type is too small, Ctrl+ is your friend

Saturday, February 22, 2025

Permutations

Factoring and Permutations Spreadsheet

Talking at lunch Tuesday*, Dennis mentioned he was playing with numbers, specifically looking for interesting patterns in permutations of a four digit number. Why? Because it's there, that's why.

I got to wondering if you could factor a number using a spreadsheet. Since we are limiting ourselves to four digit numbers, there will be no factors greater than 100. There are only 25 prime numbers under 100, so it shouldn't be too bad.

The spreadsheet is full of formulas, but I only had to figure out a couple of them and then copy and paste them to make the whole sheet.

The spreadsheet is not very smart. The largest number of factors a 4 digit number can have is 13. Two to the 13th power is 8192. Add a 14th factor and the product will have 5 digits. So 13 is the largest number of times we will have to divide.

We simply divide our starting number by our chosen factor and then count the number of times the division came out even. Our quotient becomes the starting value for the next line and the next factor.

Next I tried my hand at generating permutations. This one didn't work out quite so well. I ended up generating the permutations by hand (there are 24 permutations of 4 character strings) and then using those values to extract digits from the original 4-digit number.

Today I worked on a way to generate permutations automatically. It works, but criminently, it took a bunch of equations. 

I used string functions to cut up the number which means it should work for any four characters. It could probably be done using mathematical operations. I don't know if that would be any simpler.

*Tuesday three months ago.

2 comments:

CT Ginger said...

Start with a four digit number, any four digits. To save time dont start with a zero and use four different numerals. Arrange them in descending order and then ascending order. Subtract the small number from the large number. Arrange them in descending resulting four digits as before. Descending and ascending. If you have fewer than four digits provide initial zeros. Continue this process until you get to 6174. You will get to 6175 irrespective of whatever numbers you started with. It’s called Kaprykar’s constant.

CT Ginger said...

6174 that is