puzzles (8-15-08)

BCS ao at pathlink.com
Sat Aug 16 14:03:46 PDT 2008


Reply to Christopher,

> 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.
> 

The only practical way to do this would be an intelligent search.

get out the discrete book and start manipulating this:
(D*10^n + M) % (10*M + D) && M < 10^n




More information about the Digitalmars-d-learn mailing list