# Programming Elixir 1.6:exercise solutions - Lists and Recursion-7

**URL:** <https://forum.devtalk.com/t/programming-elixir-1-6-exercise-solutions-lists-and-recursion-7/166612>\
**Category:** PragProg Customers\
**Tags:** book-programming-elixir-1-6, errata\
**Created:** [17 August 2024 14:26 UTC](https://forum.devtalk.com/t/programming-elixir-1-6-exercise-solutions-lists-and-recursion-7/166612 "2024-08-17T14:26:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rope-a-dope](https://forum.devtalk.com/user_avatar/forum.devtalk.com/rope-a-dope/32/6461_2.png) [@Rope-a-dope](https://forum.devtalk.com/u/Rope-a-dope)\
**Post date:** [17 August 2024 14:26 UTC](https://forum.devtalk.com/t/programming-elixir-1-6-exercise-solutions-lists-and-recursion-7/166612/1 "2024-08-17T14:26:27Z")

</div>

### @pragdave

The correct one should be

````auto
defmodule Hello.Elixir do
  def span(from, to) when from > to, do: []
  def span(from, to), do: [from | span(from + 1, to)]

  def primes_up_to(n) do
    range = span(2, n)
    range -- for a <- range, b <- range, a <= b, a * b <= n, do: a * b
  end
end```
````
