Created
July 11, 2016 03:01
-
-
Save Chubek/b4c34246aa17a7cff06c2ad7429ecf7d to your computer and use it in GitHub Desktop.
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; | |
namespace ZeckendorfRepresentation | |
{ | |
class Program | |
{ | |
public static List<long> Fibonacci = new List<long>() { 0, 1 }; | |
public static List<long> ZeckendorfRep = new List<long>(); | |
static void Main(string[] args) | |
{ | |
long input = long.Parse(Console.ReadLine()); | |
Fbonacci_Init(input); | |
FindLesser(input); | |
foreach (var number in ZeckendorfRep) | |
{ | |
Console.WriteLine(number); | |
} | |
Console.ReadKey(); | |
} | |
static void Fbonacci_Init(long roof) | |
{ | |
for (int i = 1; i < roof; i++) | |
{ | |
Fibonacci.Add(Fibonacci[i - 1] + Fibonacci[i]); | |
} | |
} | |
static void FindLesser(long number) | |
{ | |
for (int i = Fibonacci.Count - 1; i >= 0; i--) | |
{ | |
if (Fibonacci[i] <= number) | |
{ | |
ZeckendorfRep.Add(Fibonacci[i]); | |
break; | |
} | |
} | |
} | |
static void Difference(long init) | |
{ | |
ZeckendorfRep.Add(init - ZeckendorfRep[0]); | |
while (ZeckendorfRep.Sum() != init) | |
{ | |
int i = 1; | |
while (i < ZeckendorfRep.Count) | |
{ | |
ZeckendorfRep.Add(ZeckendorfRep[i - 1] - ZeckendorfRep[i]); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment