## Project Euler #29

The problem states How many distinct terms are in the sequence generated by

*a*for 2 ≤^{b}*a*≤ 100 and 2 ≤*b*≤ 100?*Answer*:

**9183**

*Solution*: As I mentioned in my other post, I use my little helper GenerateNumbers method to get my sequence. Also I couldn’t use the built-in C# data types. So I used F# BigInt.

var lOutput = from lB in FunExtensions.GenerateNumbers(2, 100, pInt => pInt) from lA in FunExtensions.GenerateNumbers(2, 100, pArg => BigInt.Pow(new BigInt(pArg), new BigInt(lB))) orderby lA select lA; return lOutput.Distinct().Count();

Time: 121 ms

Advertisements

## Leave a Reply