Last active
May 31, 2018 21:06
-
-
Save vmandic/a2039a872d14682940593ae38cbb3acb to your computer and use it in GitHub Desktop.
Gets double Eureka numbers for a range from a to b.
This file contains hidden or 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 IEnumerable<double> Eurekas(double a, double b) | |
{ | |
for (;a <= b;a++) | |
if (a.ToString().Select((c, i) => Math.Pow(Char.GetNumericValue(c), i + 1)).Sum() == a) | |
yield return a; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment