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:

```d
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


Reply via email to