Octal Prime Numbers (challenge)
Salih Dincer
salihdb at hotmail.com
Tue Jun 25 06:44:28 UTC 2024
Hello, I discovered something about octal prime numbers. I don't
know if anyone has dealt with this before, but thanks to the
power of the D programming language, it was very easy. So, by
defining a range with the empty(), front() and popFront()
functions, I produced an output, something like this:
> ~ dmd main.d -ofmain.out
> ~ ./main.out
> 00000000000000000005: 5, 0
> 00000000000000000045: 37, 1
> 00000000000000000445: 293, 2
> 00000000000000004445: 2341, 3
> 00000000000044444445: 9586981, 7
> 00000000004444444445: 613566757, 9
> 00000000044444444445: 4908534053, 10
> 44444444444444444445: 658812288346769701, 19
> ...
> 4...4444444444444445: ? (hint: greater than 100 bits)
In order, they are as follows "octal: decimal, and number of
repetitions (¹⁰¹) and they are all prime 8 numbers! So what's the
ninth? I'm not sharing the code for now because it's a challenge.
But you should use std.bigint module and simply shift left and
add octal 4 or binary 101.
SDB at 79
More information about the Digitalmars-d-learn
mailing list