aboutsummaryrefslogtreecommitdiff
path: root/entries/MarieSal0/FibonacciWorkplace/Program.cs
diff options
context:
space:
mode:
authorfunemy2022-10-25 07:14:52 +0000
committerfunemy2022-10-25 07:14:52 +0000
commit998ef837b43203319397f191036a97a5adc42220 (patch)
tree920558bd60d282c663fd2da1cd4144cac1849a1d /entries/MarieSal0/FibonacciWorkplace/Program.cs
parentfdac6c60e115297a58f5b81da0c4b7f18ac758f2 (diff)
parentce7544a6db594f7d3dfad0d7dc65d01515e57ad6 (diff)
Merge branch 'main' of github.com:braxtonhall/fib
Diffstat (limited to 'entries/MarieSal0/FibonacciWorkplace/Program.cs')
-rw-r--r--entries/MarieSal0/FibonacciWorkplace/Program.cs41
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