BaşlayınÜcretsiz başlayın

Fibonacci sequence

You are working on a script to calculate the Fibonacci sequence. The Fibonacci sequence is a famous sequence of numbers that appears in nature in many places.

The first two numbers in the sequence are 0 and 1. The numbers after that are each equal to the sum of the two numbers which come before them. So the start of the sequence is 0, 1, 1, 2, 3, 5,....

The first several digits of the Fibonacci sequence have been calculated for you and are stored in the integer array fibonacci, which is available in your environment.

Bu egzersiz, kursun bir parçasıdır

Introduction to Julia

Kursa Göz Atın

Egzersiz talimatları

  • Calculate the next number in the sequence fibonacci by adding its last two terms.
  • Add the new term to the end of the fibonacci array using the push!() function.

Uygulamalı etkileşimli egzersiz

Bu egzersizi bu örnek kodu tamamlayarak deneyin.

# Calculate the next number in the sequence
next_number = ____ + ____

# Add this new number to the sequence
____(____, ____)

println(fibonacci)
Kodu Düzenle ve Çalıştır