Skip to content

Instantly share code, notes, and snippets.

@dzsquared
Created December 30, 2016 02:44
Show Gist options
  • Save dzsquared/3704140d18d860223c758e434747ab32 to your computer and use it in GitHub Desktop.
Save dzsquared/3704140d18d860223c758e434747ab32 to your computer and use it in GitHub Desktop.
fib sequence created by dzsquared - https://repl.it/Exxp/0
using System;
using System.Collections.Generic;
using System.IO;
class Solution {
static void Main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution */
string[] theInput = Console.ReadLine().Split(' ');
int howFar = Convert.ToInt32(theInput[2]);
ulong[] theResults = new UInt64[howFar+2];
theResults[0] = Convert.ToUInt64(theInput[0]);
theResults[1] = Convert.ToUInt64(theInput[1]);
for(int i = 2; i <= howFar; i++) {
theResults[i] = theResults[i-2]+(theResults[i-1]*theResults[i-1]);
Console.WriteLine(theResults[i]);
}
Console.WriteLine(theResults[howFar-1]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment