Last active
August 5, 2018 20:20
-
-
Save sandfoxdev/73b0f486e85e8d170ff18e216b9fa6a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static string ListSquared(long _m, long _n) { | |
string result = ""; | |
int m=(int)_m, n=(int)_n; | |
for (int i = m; i <= n; i++) { | |
int range = Enumerable.Range(1, i).Where(x => i % x == 0).Sum(x => x * x); | |
double round = Math.Sqrt(range); | |
if (round == Math.Round(round)) { | |
string sum = string.Format("[{0}, {1}]", i.ToString(), range.ToString()); | |
if (result == "") | |
result = sum; | |
else | |
result = result + ", " + sum; | |
} | |
} | |
return "[" + result + "]"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment