Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/Pernicious-numbers/Miranda/pernicious-numbers.miranda
Normal file
18
Task/Pernicious-numbers/Miranda/pernicious-numbers.miranda
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
main :: [sys_message]
|
||||
main = [Stdout (lay (map show [first25, large]))]
|
||||
|
||||
first25 :: [num]
|
||||
first25 = take 25 (filter pernicious [1..])
|
||||
|
||||
large :: [num]
|
||||
large = filter pernicious [888888877..888888888]
|
||||
|
||||
pernicious :: num->bool
|
||||
pernicious = prime . popcount
|
||||
|
||||
popcount :: num->num
|
||||
popcount 0 = 0
|
||||
popcount n = n mod 2 + popcount (n div 2)
|
||||
|
||||
prime :: num->bool
|
||||
prime n = n >= 2 & and [n mod d ~= 0 | d<-[2..sqrt n]]
|
||||
Loading…
Add table
Add a link
Reference in a new issue