Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
25
Task/Population-count/Mathematica/population-count.math
Normal file
25
Task/Population-count/Mathematica/population-count.math
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
popcount[n_Integer] := IntegerDigits[n, 2] // Total
|
||||
Print["population count of powers of 3"]
|
||||
popcount[#] & /@ (3^Range[0, 30])
|
||||
(*******)
|
||||
evilQ[n_Integer] := popcount[n] // EvenQ
|
||||
evilcount = 0;
|
||||
evillist = {};
|
||||
i = 0;
|
||||
While[evilcount < 30,
|
||||
If[evilQ[i], AppendTo[evillist, i]; evilcount++];
|
||||
i++
|
||||
]
|
||||
Print["first thirty evil numbers"]
|
||||
evillist
|
||||
(*******)
|
||||
odiousQ[n_Integer] := popcount[n] // OddQ
|
||||
odiouscount = 0;
|
||||
odiouslist = {};
|
||||
i = 0;
|
||||
While[odiouscount < 30,
|
||||
If[odiousQ[i], AppendTo[odiouslist, i]; odiouscount++];
|
||||
i++
|
||||
]
|
||||
Print["first thirty odious numbers"]
|
||||
odiouslist
|
||||
Loading…
Add table
Add a link
Reference in a new issue