Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
# Auto Code Example - Fibonacci

**Model**: claude-3-haiku-20240307

A simple example generated without context just to check everything is working.

## Prompt

> Generate a javascript program that will generate the nth fibonacci number.

## Model Response

Okay, let's generate a JavaScript program to calculate the nth Fibonacci number.
Creating file: fibonacci.js
The key steps are:

1. Define a `fibonacci` function that takes an integer `n` as input.
2. If `n` is 0 or 1, return `n` as the Fibonacci number.
3. Otherwise, recursively call `fibonacci(n-1)` and `fibonacci(n-2)` and return their sum.
4. Log the 10th Fibonacci number to the console to test the function.

This implements the classic recursive definition of the Fibonacci sequence, where each number is the sum of the previous two. You can call the `fibonacci` function with any positive integer `n` to get the nth Fibonacci number.

Let me know if you have any other questions!
8 changes: 8 additions & 0 deletions generated/fibonacci.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function fibonacci(n) {
if (n <= 1) {
return n;
}
return fibonacci(n - 1) + fibonacci(n - 2);
}

console.log(fibonacci(10)); // Output: 55