Puzzle 8-13-2008 (answers)

BCS ao at pathlink.com
Wed Aug 13 12:38:29 PDT 2008


Reply to Steven,

> I actually found these quite easy :)
> 
> BTW, to denote squared, you should use a^2, the way you wrote the
> third problem had me very confused for a while :)  I thought there was
> a constraint like: a*10 + 2 + b*10 + 2 == c * 10 + 2.
> 

ditto, i didn't even bother because of that

> import tango.io.Stdout;
> 
> void prob1()
> {
> int s = 0;
> for(int i = 1; i < 1000; i++)
> {
> if(i % 3 == 0 || i % 5 == 0)
> s += i;
> }
> Stdout(s).newline;
> }

nice

> void prob2()
> {
> auto target= 600_851_475_143;
> for(ulong i = 3; i * i < target; i++)
> if(target % i == 0)
> {
> Stdout(i).newline;
> return;
> }
> Stdout(target)(" is prime!").newline;
> }

doesn't that find the smallest factor?




More information about the Digitalmars-d-learn mailing list