Problem 39

Construct a list of all prime numbers within a range of integers.

Example:

primesInRange 10 20 == [11,13,17,19]

Unit Test

import Html
import List


primesInRange : Int -> Int -> List Int
primesInRange low high =
    -- your implementation here
    []


main : Html.Html a
main =
    Html.text
        <| case test of
            0 ->
                "Your implementation passed all tests."

            1 ->
                "Your implementation failed one test."

            x ->
                "Your implementation failed " ++ (toString x) ++ " tests."


test : Int
test =
    List.length
        <| List.filter ((==) False)
            [ primesInRange 1 36 == [2,3,5,7,11,13,17,19,23,29,31]
            , primesInRange 1 10 == [2,3,5,7]
            , primesInRange -1 1 == []
            , primesInRange 1 1 == []
            , primesInRange 100 1 == []
            , primesInRange 0 1 == []
            , primesInRange 60 100 == [61,67,71,73,79,83,89,97]
            , primesInRange 4 10 == [5, 7]
            , primesInRange 24 100 == [29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]
            ]

Hints

  1. Modify the solution from Problem 31.

Solutions

Solutions

results matching ""

    No results matching ""