I'm new to coding and want to make a code in wolfram mathematica. What I want to do is decompose a perfect number into fractions for each digit.
Example for the 2nd perfect number: I want 28 to be written as 20/100 and 8/100. I want to do this for the bigger perfect numbers aswell so I need a general code.
Next I want to find the ammount common divisors of 20 and 100. (which is 6) and the amount of common divisors of 8 and 100 (which is 3).
Now seems simple but for bigger numbers I get discrepancies between wolfram alpha calculations and wolfram mathematica calculations.
I can't really find the problem but the list I found was:
1st (x) 3
2nd (y) 6 3
3rd (z) 12 4 2
4th (g) 16 9 6 4
5th (t) 64 49 42 30 0 9 4 2
6th (r) 110 90 88 49 54 30 16 0 6 2
but I get a different output in mathematica. It seems that mathematica doubles some numbers and some times it just adds a few (for the 3rd number I get 12, 4, and 2 but mathematica gives me 15, 12, and 4)
The code I made up until now is:
(* Definieer het perfecte nummer dat u wilt analyseren *)
perfectNumber = PerfectNumber[6];
(* Converteer het perfecte nummer naar een lijst van zijn cijfers *)
digits = IntegerDigits[perfectNumber];
(* Bepaal het aantal cijfers in het perfecte nummer *)
numDigits = Length[digits];
(* Positioneer de cijfers op basis van hun plaats in het perfecte nummer *)
positionedDigits = MapIndexed[#1 10^(numDigits - #2[[1]]) &, digits];
(* Verdeel elk gepositioneerd cijfer door het aantal cijfers in het perfecte nummer *)
dividedDigits = Map[#/10^numDigits &, positionedDigits];
(* Bepaal de delers van elk gepositioneerd cijfer *)
numeratorDivisors = Map[Divisors, positionedDigits];
(* Bepaal het aantal delers van elk gepositioneerd cijfer *)
numDivisors = Map[Length, numeratorDivisors];