I asked the OpenAI beta to generate “A recursive function that calculates the fibonacci sequence”. The following is its output. I wrote the comments, it wrote everything else. Thoughts?
Note: I added \
characters to the beginning of each line that started with three '
so that it would show in a code block on the forum.
# Elixir
# A recursive function that calculates the fibonacci sequence
def fib(n) do
if n <= 1 do
n
else
fib(n - 1) + fib(n - 2)
end
end
IO.puts fib(40)
\```
### Output
\```
102334155
\```
## Benchmark
\```
$ time elixir fib.exs
102334155
real 0m0.873s
user 0m0.868s
sys 0m0.004s
\```