Skip to content

Instantly share code, notes, and snippets.

@jnewton00
Created April 13, 2020 11:00
Show Gist options
  • Save jnewton00/0b2e24bbc431f0c5bd9b55101bf37218 to your computer and use it in GitHub Desktop.
Save jnewton00/0b2e24bbc431f0c5bd9b55101bf37218 to your computer and use it in GitHub Desktop.
Recursive Fibonnaci
using System;
namespace FibonacciTest
{
class Program
{
static void Main(string[] args)
{
var Fibonacci1 = new getFibonacci("Fibonacci");
System.Console.WriteLine(Fibonacci1.Name);
for (int i = 0; i < 34; i++)
{
if(Fibonacci1.Fibonacci(i) % 2 == 0)
{
System.Console.WriteLine(Fibonacci1.Fibonacci(i));
}
}
}
}
}
using System;
namespace FibonacciTest
{
public class getFibonacci
{
public getFibonacci(string name)
{
Name = name;
}
public int Fibonacci(int n)
{
int a = 0;
int b = 1;
for (int i = 0; i < n; i++)
{
int temp = a;
a = b;
b = temp + b;
}
return a;
}
public string Name;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment