Skip to content

Instantly share code, notes, and snippets.

@Chubek
Created July 11, 2016 03:01
Show Gist options
  • Save Chubek/b4c34246aa17a7cff06c2ad7429ecf7d to your computer and use it in GitHub Desktop.
Save Chubek/b4c34246aa17a7cff06c2ad7429ecf7d to your computer and use it in GitHub Desktop.
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