Created
February 16, 2018 16:08
-
-
Save paulohenriquesn/6e3f572fbcc4fe2f627e2bab202061eb to your computer and use it in GitHub Desktop.
fibonacci.cs
This file contains hidden or 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
RestartFibonacci: | |
{ | |
List<int> arrayNumbers = new List<int>(); | |
arrayNumbers.Add(0); | |
arrayNumbers.Add(1); | |
string fibonacci = String.Empty; | |
for (int i = 0; i < arrayNumbers.Count; i++) | |
{ | |
fibonacci += arrayNumbers[i] + ","; | |
} | |
string[] splitFibonacci = fibonacci.Split(','); | |
int[] arrayToValues = new int[splitFibonacci.Length - 1]; | |
for (int i = 0; i < splitFibonacci.Length; i++) { try { arrayToValues[i] = int.Parse(splitFibonacci[i]); } catch { } } | |
Console.WriteLine(string.Join(",", arrayToValues)); | |
for (int b = 0; b < arrayToValues.Length; b++) | |
{ | |
try | |
{ | |
int value = arrayToValues[b] + arrayToValues[b + 1]; | |
arrayNumbers.Add(value); | |
fibonacci = String.Empty; | |
goto RestartFibonacci; | |
} | |
catch { } | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment