Skip to content

Commit

Permalink
Tweak to problem 70
Browse files Browse the repository at this point in the history
  • Loading branch information
ckknight committed Jun 8, 2010
1 parent 6ed5d10 commit ed587a8
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions Ckknight.ProjectEuler/Problems/Problem070.cs
Expand Up @@ -36,16 +36,15 @@ public override object CalculateResult()
n = x.n,
t = x.n - (x.p + x.q) + 1
})
.Concat(PrimeGenerator.Instance.AsParallel((long)Math.Sqrt(10000000))
.Select(p => new
{
n = p*p,
t = p*p - p,
}))
.Where(x => MathUtilities.ToDigits(x.t).IsPermutation(MathUtilities.ToDigits(x.n)))
.WithMin(x => (double)x.n / (double)x.t)
.n;
}

public long Phi(long n)
{
return new PrimeFactorGenerator(n)
.Distinct()
.Aggregate(n, (x, p) => x * (p - 1) / p);
}
}
}

0 comments on commit ed587a8

Please sign in to comment.