Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
August 15, 2008 puzzles (8-15-08) | ||||
---|---|---|---|---|
| ||||
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! |
August 15, 2008 Re: puzzles (8-15-08) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Wyverex | Wyverex, el 15 de agosto a las 11:30 me escribiste: > 2 and 3 from the other day are time consuming but are good practice for new programmers! Hi! No offense, but I find this constant Puzzle posts a little annoying. Is there any chance you can move it to another list where just interested people can subscribe? Thank you! -- Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/ ---------------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ---------------------------------------------------------------------------- Hello? Is there anybody in there? Just nod if you can hear me. Is there anyone at home? |
August 15, 2008 Re: puzzles (8-15-08) Ping Walter | ||||
---|---|---|---|---|
| ||||
Posted in reply to Leandro Lucarella | Reply to Leandro,
> Wyverex, el 15 de agosto a las 11:30 me escribiste:
>
>> 2 and 3 from the other day are time consuming but are good practice
>> for new programmers!
>>
> Hi! No offense, but I find this constant Puzzle posts a little
> annoying. Is there any chance you can move it to another list where
> just interested people can subscribe?
>
> Thank you!
>
A NG is really nice for this type of thing (not all posts are shown until you open them and it's threaded)
Hay Walter! Any Way to talk you into adding an OT newsgroup?
|
August 16, 2008 Re: puzzles (8-15-08) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Wyverex | 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.
|
August 16, 2008 Re: puzzles (8-15-08) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Christopher Wright | 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
|
Copyright © 1999-2021 by the D Language Foundation