Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
perfect numbers
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
--ghc 8.0.1 /opt/ghc/8.0.1/lib/ghc-8.0.0.20160127/ divs n = filter (\x -> n `rem` x == 0) [1..n] isPerfect n = (sum . divs) n == n + n per = filter (isPerfect) [1..] showPer1 = map (\n -> (n , divs n)) per isPrime x = all (\k -> x `rem` k /= 0) [2..x-1] getPrimes [] = [] getPrimes (1:xs) = getPrimes xs getPrimes (x:xs) = x:getPrimes (filter (\k -> k `rem` x /= 0) xs) primes = getPrimes [1..] isM p = isPrime (2 ^ p - 1) mPrimes = (map (\p -> 2 ^ p - 1) . filter isM) primes euclidF p = 2^(p-1) * (2^p -1) euclidPer = (map euclidF . filter isM) primes main = do print $ 6 -- print $ take 4 showPer1 -- print $ take 7 euclidPer
ghc
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
Compilation time: 0.62 sec, absolute running time: 2.34 sec, cpu time: 2.23 sec, memory peak: 3 Mb, absolute service time: 2,96 sec
fork mode
|
history
|
discussion