Created
February 28, 2017 22:43
-
-
Save Logxn/5cb5dcef926cf6ade892499c2b52e13f to your computer and use it in GitHub Desktop.
pNacho
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Numerics; | |
using System.Threading; | |
namespace Fibonacho | |
{ | |
class Program | |
{ | |
static bool found; | |
static void Main(string[] args) | |
{ | |
Console.Write($"Please enter the length of the Fibonacci Number: "); | |
var länge = Convert.ToInt32(Console.ReadLine()); | |
Fibonacho(länge); | |
} | |
static void Fibonacho(int lenghtx) | |
{ | |
BigInteger vorletzte = 0; | |
BigInteger letzte = 1; | |
BigInteger index = 2; | |
Console.WriteLine("Counting.."); | |
while (!found) | |
{ | |
BigInteger thisnum = vorletzte + letzte; | |
vorletzte = letzte; | |
letzte = thisnum; | |
int length = thisnum.ToString().Length; | |
if (length == lenghtx) | |
{ | |
found = true; | |
Console.WriteLine($"Found: {thisnum} - Index: {index} - Length: {length}"); | |
} | |
index++; | |
} | |
Thread.Sleep(TimeSpan.FromSeconds(5)); | |
Console.Read(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment