- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Large Fibonacci Numbers in C#
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
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; } } }
Advertisements