Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
project euler 10, haskell
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
--http://www.haskell.org/haskellwiki/Euler_problems/1_to_10 --The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. --Find the sum of all the primes below one million. primes = 2 : filter ((==1) . length . primeFactors) [3,5..] primeFactors n = factor n primes where factor n (p:ps) | p*p > n = [n] | n `mod` p == 0 = p : factor (n `div` p) (p:ps) | otherwise = factor n ps problem_10 = sum (takeWhile (< 1000000) primes) main = print $ problem_10
ghc
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
Compilation time: 0.32 sec, absolute running time: 2.76 sec, cpu time: 2.66 sec, memory peak: 9 Mb, absolute service time: 3.24 sec
fork mode
|
history
|
discussion
37550402023