# Large Fibonacci Numbers in C#

CsharpProgrammingServer Side Programming

#### Complete Python Prime Pack

9 Courses     2 eBooks

#### Artificial Intelligence & Machine Learning Prime Pack

6 Courses     1 eBooks

#### Java Prime Pack

9 Courses     2 eBooks

To display large Fibonacci numbers, try the following login and code.

Here, we have set the value of n as the series. Set it to get the Fibonacci number. Below, we have set it to 100 to get the first 100 Fibonacci numbers.

Since the first two numbers in a Fibonacci series are 0 and 1. Therefore, we will set the first two values.

int val1 = 0, val2 = 1;

The following is the complete code to display large Fibonacci numbers.

## Example

Live Demo

using System;
public class Demo {
public static void Main(string[] args) {
int val1 = 0, val2 = 1, val3, i, n;
n = 40;
Console.WriteLine("Displaying Fibonacci series:");
Console.Write(val1+" "+val2+" ");
for(i=2;i<n;++i) {
val3 = val1 + val2;
Console.Write(val3+"");
val1 = val2;
val2 = val3;
}
}
}

Updated on 22-Jun-2020 08:33:12