-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMath.cs
28 lines (28 loc) · 1.31 KB
/
Math.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System;
using System.Collections.Generic;
namespace Codenation.Challenge
{
public class Math
{
public List<int> Fibonacci()
{
int maxfibo = 350; // maxfibo is maximum number desired the fibonacci series
List<int> fibo = new List<int>(); // creation of the list named fibo
var aux = 1; // aux is utilized to receiver fibo'
var i = 0; //counter
fibo.Add(0); // first value of fibonacci's series
while ((fibo[i] + aux) < maxfibo) // while value < maxfibo implement new number
{
i += 1;
fibo.Add(fibo[i - 1] + aux);
aux = fibo[i - 1];
}
return fibo; // return the list with the fibonacci series
}
public bool IsFibonacci(int numberToTest) // test if the list contains the numberToTest
{
List<int> listfibo = Fibonacci();
return listfibo.Contains(numberToTest) ? (true) : (false);
}
}
}