Fixed code warnings

This commit is contained in:
2020-10-03 12:51:21 -04:00
parent 73611cb527
commit e2be18dbaf
2 changed files with 9 additions and 9 deletions

View File

@@ -35,7 +35,7 @@ namespace ProjectEulerCS.Problems{
private const int BOTTOM_B = 2; //The lowest possible value for b private const int BOTTOM_B = 2; //The lowest possible value for b
private const int TOP_B = 100; //The highest possible value for b private const int TOP_B = 100; //The highest possible value for b
//Instance variables //Instance variables
private List<BigInteger> unique; //Holds all unique values generated private readonly List<BigInteger> unique; //Holds all unique values generated
//Gets //Gets
public static int BottomA{ public static int BottomA{
get{ get{

View File

@@ -34,7 +34,7 @@ namespace ProjectEulerCS.Problems{
private const long BOTTOM_NUM = 2; //Starts with 2 because 0 and 1 don't count private const long BOTTOM_NUM = 2; //Starts with 2 because 0 and 1 don't count
private const long POWER_RAISED = 5; //Starts with 2 because 0 and 1 don't count private const long POWER_RAISED = 5; //Starts with 2 because 0 and 1 don't count
//Instance variables //Instance variables
private List<long> sumOfFifthNumbers; //This is an ArrayList of the numbers that are the sum of the fifth power of their digits private readonly List<long> SumOfFifthNumbers; //This is an ArrayList of the numbers that are the sum of the fifth power of their digits
//Gets //Gets
public long TopNum{ public long TopNum{
get{ get{
@@ -49,7 +49,7 @@ namespace ProjectEulerCS.Problems{
if(!solved){ if(!solved){
throw new Unsolved(); throw new Unsolved();
} }
return sumOfFifthNumbers; return SumOfFifthNumbers;
} }
} }
public long GetSumOfList{ public long GetSumOfList{
@@ -57,7 +57,7 @@ namespace ProjectEulerCS.Problems{
if(!solved){ if(!solved){
throw new Unsolved(); throw new Unsolved();
} }
return mee.Algorithms.GetSum(sumOfFifthNumbers); return mee.Algorithms.GetSum(SumOfFifthNumbers);
} }
} }
public override string Result{ public override string Result{
@@ -72,11 +72,11 @@ namespace ProjectEulerCS.Problems{
//Functions //Functions
//Operational functions //Operational functions
public Problem30() : base("Find the sum of all the numbers that can be written as the sum of the fifth powers of their digits."){ public Problem30() : base("Find the sum of all the numbers that can be written as the sum of the fifth powers of their digits."){
sumOfFifthNumbers = new List<long>(); SumOfFifthNumbers = new List<long>();
} }
//Operational functions //Operational functions
//Returns an ArrayList with the individual digits of the number passed to it //Returns an ArrayList with the individual digits of the number passed to it
private List<long> getDigits(long num){ private List<long> GetDigits(long num){
List<long> listOfDigits = new List<long>(); //This ArrayList holds the individual digits of num List<long> listOfDigits = new List<long>(); //This ArrayList holds the individual digits of num
//The easiest way to get the individual digits of a number is by converting it to a string //The easiest way to get the individual digits of a number is by converting it to a string
string digits = num.ToString(); string digits = num.ToString();
@@ -100,7 +100,7 @@ namespace ProjectEulerCS.Problems{
//Start with the lowest number and increment until you reach the largest number //Start with the lowest number and increment until you reach the largest number
for(long currentNum = BOTTOM_NUM;currentNum <= TOP_NUM;++currentNum){ for(long currentNum = BOTTOM_NUM;currentNum <= TOP_NUM;++currentNum){
//Get the digits of the number //Get the digits of the number
List<long> digits = getDigits(currentNum); List<long> digits = GetDigits(currentNum);
//Get the sum of the powers //Get the sum of the powers
long sumOfPowers = 0; long sumOfPowers = 0;
foreach(long num in digits){ foreach(long num in digits){
@@ -109,7 +109,7 @@ namespace ProjectEulerCS.Problems{
//Check if the sum of the powers is the same as the number //Check if the sum of the powers is the same as the number
//If it is, add it tot he list, owtherwise continue to the next number //If it is, add it tot he list, owtherwise continue to the next number
if(sumOfPowers == currentNum){ if(sumOfPowers == currentNum){
sumOfFifthNumbers.Add(currentNum); SumOfFifthNumbers.Add(currentNum);
} }
} }
@@ -122,7 +122,7 @@ namespace ProjectEulerCS.Problems{
//Reset the problem so it can be run again //Reset the problem so it can be run again
public override void Reset(){ public override void Reset(){
base.Reset(); base.Reset();
sumOfFifthNumbers.Clear(); SumOfFifthNumbers.Clear();
} }
} }
} }