Puzzle 8-13-2008
Wyverex
wyverex.cypher at gmail.com
Wed Aug 13 13:19:11 PDT 2008
Steven Schveighoffer wrote:
>
> 1472 is not prime.
>
> Hint for doing prime stuff, don't use floating point types :)
>
> Also, the second to last line, taking the max of l and m is questionable.
>
> -Steve
>
Wow I messed that up!
//Proper way I should have done it!!!
import tango.io.Stdout;
void main()
{
ulong i = 600851475143;
ulong l = 2;
while(l*l <= i)
{
if(i%l == 0)
{
Stdout(l)(" ");
i /= l;
}
++l;
}
Stdout(i).newline;
Stdout("Max:")(i).newline;
}
Output:
71 839 1471 6857
Max:6857
More information about the Digitalmars-d-learn
mailing list