Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

Lucas Numbers

lucas_numbers.livemd

Lucas Numbers

Mix.install([
  {:kino, github: "livebook-dev/kino", override: true},
  {:kino_lab, "~> 0.1.0-dev", github: "jonatanklosko/kino_lab"},
  {:vega_lite, "~> 0.1.4"},
  {:kino_vega_lite, "~> 0.1.1"},
  {:benchee, "~> 0.1"},
  {:ecto, "~> 3.7"},
  {:math, "~> 0.7.0"},
  {:faker, "~> 0.17.0"},
  {:utils, path: "#{__DIR__}/../utils"},
  {:tested_cell, git: "https://github.com/BrooklinJazz/tested_cell"}
])

Navigation

Return Home Report An Issue

Lucas Numbers

This exercise was inspired by Exercism.io. It’s A fantastic platform for learning many languages including Elixir.

Lucas numbers are much like the fibonacci sequence where $fib(n) = fib(n - 1) + fib(n - 2)$ Numberphile has a great video that explains them in further detail,

Kino.YouTube.new("https://www.youtube.com/watch?v=PeUbRXnbmms")

Unlike Fibonacci, they start with a different initial 2 numbers.

Commonly it will start with 2, 1, so:

flowchart LR
  2 --> 1 --> 3 --> 4 --> 7 --> 11 --> 18 --> 29 --> ...

In the Elixir cell below, implement the LucasNumbers.generate/1 function that will generate a Lucas number sequence starting with 2, 1.

LucasNumbers.generate(1)
[1]

LucasNumbers.generate(2)
[2, 1]

LucasNumbers.generate(3)
[2, 1, 3]

Other than starting with two different numbers, the formula for a lucas number is still $L(n)=L(n-1)+L(n - 2)$.

defmodule LucasNumbers do
  def generate(n) do
  end
end

Utils.feedback(:lucas_numbers, LucasNumbers)

Commit Your Progress

Run the following in your command line from the project folder to track and save your progress in a Git commit.

$ git add .
$ git commit -m "finish lucas numbers exercise"