Created
April 13, 2020 11:00
-
-
Save jnewton00/0b2e24bbc431f0c5bd9b55101bf37218 to your computer and use it in GitHub Desktop.
Recursive Fibonnaci
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; | |
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