Skip to content

Instantly share code, notes, and snippets.

@vmandic
Last active May 31, 2018 21:06
Show Gist options
  • Save vmandic/a2039a872d14682940593ae38cbb3acb to your computer and use it in GitHub Desktop.
Save vmandic/a2039a872d14682940593ae38cbb3acb to your computer and use it in GitHub Desktop.
Gets double Eureka numbers for a range from a to b.
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