diff options
author | braxtonhall | 2022-10-24 22:21:37 +0000 |
---|---|---|
committer | braxtonhall | 2022-10-24 22:21:37 +0000 |
commit | d8809640625ff7113b3e534a0ddc84d970674570 (patch) | |
tree | aa637412b211115301ed9418295b0d8ce69da2c5 /entries/MarieSal0/FibonacciWorkplace/Program.cs | |
parent | 89bd4035db8c9979b1f3c76a9aee951204f3ef59 (diff) |
Add Marie
Diffstat (limited to 'entries/MarieSal0/FibonacciWorkplace/Program.cs')
-rw-r--r-- | entries/MarieSal0/FibonacciWorkplace/Program.cs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/entries/MarieSal0/FibonacciWorkplace/Program.cs b/entries/MarieSal0/FibonacciWorkplace/Program.cs new file mode 100644 index 0000000..bac5688 --- /dev/null +++ b/entries/MarieSal0/FibonacciWorkplace/Program.cs @@ -0,0 +1,41 @@ +using System;
+namespace FibonacciWorkplace
+{
+ public class Program
+ {
+ static void Main(string[] args)
+ {
+ Console.Write("How long should the Fibonacci Series be?? ");
+ int lengthOfSeries = Convert.ToInt32(Console.ReadLine());
+ if (lengthOfSeries<=2)
+ {
+ LengthCheck(lengthOfSeries);
+ }
+ FibonacciSeries(0, 1, 1, lengthOfSeries);
+ Console.ReadKey();
+ }
+ public static void LengthCheck(int lengthOfSeries)
+ {
+ if (lengthOfSeries<=1)
+ {
+ Console.Write("The Fibonacci Series needs to be greater than 2");
+ lengthOfSeries = Convert.ToInt32(Console.ReadLine());
+ LengthCheck(lengthOfSeries);
+ }
+
+ }
+
+ public static void FibonacciSeries(int firstNumber, int secondNumber, int counter, int lengthOfSeries)
+ {
+ Console.Write(firstNumber + " ");
+ if (counter < lengthOfSeries)
+ {
+ int sum = firstNumber + secondNumber;
+ counter++;
+ FibonacciSeries(secondNumber, sum, counter, lengthOfSeries);
+ }
+ }
+
+
+ }
+}
\ No newline at end of file |