Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
27
Task/Vampire-number/Mathematica/vampire-number-1.math
Normal file
27
Task/Vampire-number/Mathematica/vampire-number-1.math
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
ClearAll[VampireQ]
|
||||
VampireQ[num_Integer] := Module[{poss, divs},
|
||||
divs = Select[Divisors[num], # <= Sqrt[num] &];
|
||||
poss = {#, num/#} & /@ divs;
|
||||
If[Length[poss] > 0,
|
||||
poss = Select[poss, Mod[#, 10] =!= {0, 0} &];
|
||||
If[Length[poss] > 0,
|
||||
poss = Select[poss, Length[IntegerDigits[First[#]]] == Length[IntegerDigits[Last[#]]] &];
|
||||
If[Length[poss] > 0,
|
||||
poss = Select[poss, Sort[IntegerDigits[num]] == Sort[Join @@ (IntegerDigits /@ #)] &];
|
||||
If[Length[poss] > 0
|
||||
,
|
||||
Sow[{num, poss}];
|
||||
True
|
||||
,
|
||||
False
|
||||
]
|
||||
,
|
||||
False
|
||||
]
|
||||
,
|
||||
False
|
||||
]
|
||||
,
|
||||
False
|
||||
]
|
||||
]
|
||||
2
Task/Vampire-number/Mathematica/vampire-number-2.math
Normal file
2
Task/Vampire-number/Mathematica/vampire-number-2.math
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
Reap[Scan[VampireQ,Range[126027]]][[2,1]]//Grid
|
||||
Reap[VampireQ[#]] & /@ {16758243290880, 24959017348650, 14593825548650} // Grid
|
||||
Loading…
Add table
Add a link
Reference in a new issue