Updated functions to match C# conventions

This commit is contained in:
2020-08-24 13:53:19 -04:00
parent 87578df40d
commit b2cab43514
2 changed files with 62 additions and 62 deletions

View File

@@ -30,7 +30,7 @@ using System.Numerics;
namespace mee{
public class Algorithms{
//These functions return a list of all Fibonacci numbers <= goalNumber
public static List<int> getAllFib(int goalNumber){
public static List<int> GetAllFib(int goalNumber){
//Setup the variables
List<int> fibNums = new List<int>();
@@ -52,7 +52,7 @@ namespace mee{
fibNums.RemoveAt(fibNums.Count - 1);
return fibNums;
}
public static List<long> getAllFib(long goalNumber){
public static List<long> GetAllFib(long goalNumber){
//Setup the variables
List<long> fibNums = new List<long>();
@@ -74,7 +74,7 @@ namespace mee{
fibNums.RemoveAt(fibNums.Count - 1);
return fibNums;
}
public static List<BigInteger> getAllFib(BigInteger goalNumber){
public static List<BigInteger> GetAllFib(BigInteger goalNumber){
//Setup the variables
List<BigInteger> fibNums = new List<BigInteger>();
@@ -97,10 +97,10 @@ namespace mee{
return fibNums;
}
//These functions return all factors of goalNumber
public static List<int> getFactors(int goalNumber){
public static List<int> GetFactors(int goalNumber){
//You need to get all the primes that could be factors of this number so you can test them
int topPossiblePrime = (int)Math.Ceiling(Math.Sqrt(goalNumber));
List<int> primes = getPrimes(topPossiblePrime);
List<int> primes = GetPrimes(topPossiblePrime);
List<int> factors = new List<int>();
//YOu need to step through each prime and see if it is a factor in the number
@@ -128,10 +128,10 @@ namespace mee{
//Return the list of factors
return factors;
}
public static List<long> getFactors(long goalNumber){
public static List<long> GetFactors(long goalNumber){
//You need to get all the primes that could be factors of this number so you can test them
long topPossiblePrime = (long)Math.Ceiling(Math.Sqrt(goalNumber));
List<long> primes = getPrimes(topPossiblePrime);
List<long> primes = GetPrimes(topPossiblePrime);
List<long> factors = new List<long>();
//YOu need to step through each prime and see if it is a factor in the number
@@ -159,10 +159,10 @@ namespace mee{
//Return the list of factors
return factors;
}
public static List<BigInteger> getFactors(BigInteger goalNumber){
public static List<BigInteger> GetFactors(BigInteger goalNumber){
//You need to get all the primes that could be factors of this number so you can test them
BigInteger topPossiblePrime = (BigInteger)Math.Exp(BigInteger.Log(goalNumber) / 2);
List<BigInteger> primes = getPrimes(topPossiblePrime);
List<BigInteger> primes = GetPrimes(topPossiblePrime);
List<BigInteger> factors = new List<BigInteger>();
//YOu need to step through each prime and see if it is a factor in the number
@@ -191,7 +191,7 @@ namespace mee{
return factors;
}
//These functions return a list with all the prime number <= goalNumber
public static List<int> getPrimes(int goalNumber){
public static List<int> GetPrimes(int goalNumber){
List<int> primes = new List<int>(); //Holds the prime numbers
bool foundFactor = false; //A flag for whether a factor of the current number has been found
@@ -235,7 +235,7 @@ namespace mee{
primes.Sort();
return primes;
}
public static List<long> getPrimes(long goalNumber){
public static List<long> GetPrimes(long goalNumber){
List<long> primes = new List<long>(); //Holds the prime numbers
bool foundFactor = false; //A flag for whether a factor of the current number has been found
@@ -279,7 +279,7 @@ namespace mee{
primes.Sort();
return primes;
}
public static List<BigInteger> getPrimes(BigInteger goalNumber){
public static List<BigInteger> GetPrimes(BigInteger goalNumber){
List<BigInteger> primes = new List<BigInteger>(); //Holds the prime numbers
bool foundFactor = false; //A flag for whether a factor of the current number has been found
@@ -325,7 +325,7 @@ namespace mee{
return primes;
}
//This function gets a certain number of primes
public static List<int> getNumPrimes(int numberOfPrimes){
public static List<int> GetNumPrimes(int numberOfPrimes){
List<int> primes = new List<int>(); //Holds the prime numbers
bool foundFactor = false; //A flag for whether a factor of the current number has been found
@@ -370,7 +370,7 @@ namespace mee{
primes.Sort();
return primes;
}
public static List<long> getNumPrimes(long numberOfPrimes){
public static List<long> GetNumPrimes(long numberOfPrimes){
List<long> primes = new List<long>(); //Holds the prime numbers
bool foundFactor = false; //A flag for whether a factor of the current number has been found
@@ -415,7 +415,7 @@ namespace mee{
primes.Sort();
return primes;
}
public static List<BigInteger> getNumPrimes(BigInteger numberOfPrimes){
public static List<BigInteger> GetNumPrimes(BigInteger numberOfPrimes){
List<BigInteger> primes = new List<BigInteger>(); //Holds the prime numbers
bool foundFactor = false; //A flag for whether a factor of the current number has been found
@@ -461,34 +461,34 @@ namespace mee{
return primes;
}
//These functions get a value from combining elements in an array
public static int getSum(List<int> ary){
public static int GetSum(List<int> ary){
return ary.Sum();
}
public static long getSum(List<long> ary){
public static long GetSum(List<long> ary){
return ary.Sum();
}
public static BigInteger getSum(List<BigInteger> ary){
public static BigInteger GetSum(List<BigInteger> ary){
BigInteger sum = 0;
foreach(BigInteger num in ary){
sum += num;
}
return sum;
}
public static int getProd(List<int> ary){
public static int GetProd(List<int> ary){
int prod = 1;
foreach(int num in ary){
prod *= num;
}
return prod;
}
public static long getProd(List<long> ary){
public static long GetProd(List<long> ary){
long prod = 1;
foreach(long num in ary){
prod *= num;
}
return prod;
}
public static BigInteger getProd(List<BigInteger> ary){
public static BigInteger GetProd(List<BigInteger> ary){
BigInteger prod = 1;
foreach(BigInteger num in ary){
prod *= num;