June 25

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@79

June 27

On Tuesday, 25 June 2024 at 06:44:28 UTC, Salih Dincer wrote:

>

I'm not sharing the code for now because
it's a challenge.

Since we couldn't get a code snippet, I'd like to share some framing code without answers:

struct SumPrimes(size_t size)
{
  import std.bigint;

  auto next = BigInt(1);
  auto power = BigInt(4);
  size_t index;

  auto empty() => index > size;
  auto front() => next + power;
  auto popFront()
  {
    // ...
    index++;
  }
}

unittest
{
  for (auto p = SumPrimes!10(); !p.empty; p.popFront())
  {
    auto n = p.front();
    if (n.isPrime)
    {
      n.writef!"%11o: ";
      n.writeln(", ", p.index);
    }
  }
}

SDB@79