Really confused by how one should use the Module[] command in two variables. For example my function here should return the DigitalRoot of a number; i.e. func[5432] -> 14 -> 5 or for func[23] -> 5.
My example uses the Module command but the solution is wrong;
Fox[a_] := Module[
{x1, x2},
x1 = 0;
x2 = a;
While[
x1 != 1,
x1 = Length[IntegerDigits[x2]];
x2 = Total[InterDigits[x2]];
Return[x2]
]
]
The Module[] and While[] don't appear to loop, so Fox[5432] = 5432 and Fox[23] = 23.
Maybe my understanding of the Module[] command is wrong.
Please help
@*to make it pointfree, e.g.Total@*IntegerDigitsor even(IntegerDigits/*Length/*(Not@*EqualTo[1])):) – Thies Heidecke Apr 17 '18 at 21:22