Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
9
Task/Lychrel-numbers/Mathematica/lychrel-numbers-1.math
Normal file
9
Task/Lychrel-numbers/Mathematica/lychrel-numbers-1.math
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
palindromeQ[n_Integer] :=
|
||||
Block[{digits = IntegerDigits[n]}, digits == Reverse@digits]
|
||||
|
||||
nextNumber[n_Integer] := n + FromDigits[Reverse@IntegerDigits@n]
|
||||
|
||||
lychrelQ[n_Integer] := !
|
||||
palindromeQ@
|
||||
Catch[Nest[If[palindromeQ[#], Throw[#], nextNumber[#]] &,
|
||||
nextNumber[n], 500]]
|
||||
1
Task/Lychrel-numbers/Mathematica/lychrel-numbers-2.math
Normal file
1
Task/Lychrel-numbers/Mathematica/lychrel-numbers-2.math
Normal file
|
|
@ -0,0 +1 @@
|
|||
candidates = Cases[Range[10000], _?(lychrelQ@# &)];
|
||||
7
Task/Lychrel-numbers/Mathematica/lychrel-numbers-3.math
Normal file
7
Task/Lychrel-numbers/Mathematica/lychrel-numbers-3.math
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
seeds = {};
|
||||
NestWhile[(seeds = {seeds, First@#};
|
||||
test = NestList[nextNumber, First@#, 10];
|
||||
DeleteCases[
|
||||
Rest[#], _?(IntersectingQ[test,
|
||||
NestList[nextNumber, #, 10]] &)]) &, candidates,
|
||||
Length@# > 0 &]; seeds = Flatten@seeds
|
||||
1
Task/Lychrel-numbers/Mathematica/lychrel-numbers-4.math
Normal file
1
Task/Lychrel-numbers/Mathematica/lychrel-numbers-4.math
Normal file
|
|
@ -0,0 +1 @@
|
|||
Length@candidates - Length@seeds
|
||||
1
Task/Lychrel-numbers/Mathematica/lychrel-numbers-5.math
Normal file
1
Task/Lychrel-numbers/Mathematica/lychrel-numbers-5.math
Normal file
|
|
@ -0,0 +1 @@
|
|||
Cases[candidates, _?(palindromeQ@# &)]
|
||||
Loading…
Add table
Add a link
Reference in a new issue