From af00a074f6e3b66e19ffff682cb7580de317afce Mon Sep 17 00:00:00 2001 From: Gareth Andrew Date: Tue, 16 Jul 2024 00:00:55 +0100 Subject: [PATCH] Generated with claude-3-haiku-20240307 --- README.md | 16 ++++++++++++++++ generated/fibonacci.js | 8 ++++++++ 2 files changed, 24 insertions(+) create mode 100644 generated/fibonacci.js diff --git a/README.md b/README.md index ceded6c..9e77a19 100644 --- a/README.md +++ b/README.md @@ -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! diff --git a/generated/fibonacci.js b/generated/fibonacci.js new file mode 100644 index 0000000..5642038 --- /dev/null +++ b/generated/fibonacci.js @@ -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 \ No newline at end of file