Skip to content

Instantly share code, notes, and snippets.

@sandfoxdev
Last active August 5, 2018 20:20
Show Gist options
  • Save sandfoxdev/73b0f486e85e8d170ff18e216b9fa6a6 to your computer and use it in GitHub Desktop.
Save sandfoxdev/73b0f486e85e8d170ff18e216b9fa6a6 to your computer and use it in GitHub Desktop.
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