On Friday, 10 August 2012 at 18:26:56 UTC, Timon Gehr wrote:
Is this what you are looking for?

import std.stdio;
import std.range        : iota;
import std.algorithm    : map, filter, joiner;
import std.typecons     : tuple;
import std.math         : sqrt, floor;

void main(){
    immutable limit = cast(size_t)floor(sqrt(1_000.0));

auto r = iota(2,limit).map!(m=>iota(1,m-1).map!(n=>tuple(m,n))).joiner
            .filter!(t=>2*t[0]*(t[0]+t[1])==1_000)
            .map!(t=>(t[0]^^4-t[1]^^4)*(2*t[0]*t[1]));

    writeln(r.front);
}

Ugh! I guess functional isn't always the best ;)

Reply via email to