Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,37 @@
|
|||
sumDigitsSquared[n_Integer] := Total[IntegerDigits[n]^2]
|
||||
stopValues = Join[{1}, NestList[sumDigitsSquared, 89, 7]];
|
||||
iterate[n_Integer] :=
|
||||
NestWhile[sumDigitsSquared, n, Intersection[stopValues, {#}] == {} &]
|
||||
|
||||
numberOfDigits = 8;
|
||||
maxSum = numberOfDigits 9^2;
|
||||
loopVariables =
|
||||
ToExpression@Table["i" <> ToString[n], {n, numberOfDigits}];
|
||||
iteratesToOne = Cases[Range@maxSum, _?(iterate[#] == 1 &)];
|
||||
allIterators =
|
||||
Flatten[{Reverse@#, 9}] & /@ Partition[loopVariables, 2, 1];
|
||||
maxCombinations = numberOfDigits!;
|
||||
|
||||
ssd =
|
||||
SparseArray[Table[n^2 -> numberOfDigits, {n, 9}], {maxSum}];
|
||||
|
||||
Do[
|
||||
variables = loopVariables[[;; digitCount]];
|
||||
iterators = allIterators[[;; digitCount - 1]];
|
||||
|
||||
Do[ssd +=
|
||||
SparseArray[
|
||||
Total[variables^2] ->
|
||||
maxCombinations/
|
||||
Times @@ (Tally[PadRight[variables, numberOfDigits]][[All,
|
||||
2]]!), {maxSum}], {i, 9}, Evaluate[Sequence @@ iterators]],
|
||||
|
||||
{digitCount, 2, numberOfDigits}];
|
||||
|
||||
onesCount =
|
||||
Total[Cases[
|
||||
ArrayRules[ssd] /.
|
||||
HoldPattern[{a_} -> b_] :> {a,
|
||||
b}, {_?(MemberQ[iteratesToOne, #] &), _}][[All, 2]]];
|
||||
|
||||
(10^numberOfDigits - 1) - onesCount
|
||||
Loading…
Add table
Add a link
Reference in a new issue