puzzles (8-15-08)
Christopher Wright
dhasenan at gmail.com
Fri Aug 15 18:51:02 PDT 2008
Wyverex wrote:
> 1) Consider the number 142857. We can right-rotate this number by
> moving the last digit (7) to the front of it, giving us 714285.
> It can be verified that 714285=5*142857.
> This demonstrates an unusual property of 142857: it is a divisor of its
> right-rotation.
>
> Find the digits of the set of all integers n, 11 < n < 10^100, that have
> this property.
>
>
>
> 2 and 3 from the other day are time consuming but are good practice for
> new programmers!
10^100 is greater than ulong.max.
I tried a version that went up to ulong.max. It logged every billion
checks. That took a few minutes (for the first billion, I mean). Getting
all the way to ulong.max would take overnight; to 10^100, ages, even if
you had a ucent primitive.
Granted, I was using ulongs on my 32-bit machine, so it wasn't optimal.
But bignums are a lot slower.
More information about the Digitalmars-d-learn
mailing list