# Function to generate the nth Fibonacci number
fib <- function(n) {
  if (n <= 0) {
    return(0)
  } else if (n == 1) {
    return(1)
  } else {
    return(fib(n - 1) + fib(n - 2))
  }
}

# Number of elements to generate
n <- 10

# Generate and print the first n elements of the Fibonacci series
for (i in 1:n) {
  print(fib(i))
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: