Fibonacci Series in Swift

Fibonacci series in swift program will print the Fibonacci number in swift program. 

Program like fibonacci series is the basic set of program for beginners who is learning swift programming language.

Fibonacci Series in Swift

The Fibonacci sequence is a collection of numbers that begins with a one or a zero and ends with a one, following the rule that each number called a Fibonacci number is equal to the sum of the two numbers before it. 

The ratios found in Fibonacci’s sequence are used to construct Fibonacci numbers and lines. 

The Fibonacci numbers 0.236, 0.382, 0.618, 1.618, 2.618, and 4.236 are commonly used in financial markets. 

Divide specific numbers in the series by other numbers to find these ratios or percentages.

Uses of Fibonacci Series

Fibonacci levels are employed as indicators of probable trade development.

Prior to acting on the Fibonacci level, the price must confirm. 

Traders cannot predict which level will be crucial in advance, so they must wait and watch which level the price respects before entering a trade.

Let vs Var

In Swift, both let and var are used to create variables.

Let aids in the creation of immutable variables constants, whereas var aids in the creation of mutable variables. 

The distinction is that when you create a constant using let, you must assign something to it before it can be used for the first time, and you cannot reassign it.

For Loop in Swift

A loop is used to repeatedly execute a set of statements until a certain condition is met.

When showing numbers from 1 to 100, for example, you might wish to set the value of a variable to 1 and display it 100 times, raising its value by 1 with each loop iteration.

var x = -1,
y = 1,
sum = 0;
for i in 0..<20
sum = x+y;
x = y;
y= sum;

Output :





Compiler: Click Here