Definitions
In mathematics, additive primes are prime numbers for which the sum of their decimal digits are also primes.



Task
Write a program to determine (and show here) all additive primes less than 500.

Optionally, show the number of additive primes.



Also see

   the OEIS entry:   A046704 additive primes.
   the prime-numbers entry:   additive primes.
   the geeks for geeks entry: additive prime number.
   the prime-numbers fandom: additive primes.


$ include "seed7_05.s7i";
 
const func boolean: isPrime (in integer: number) is func
  result
    var boolean: prime is FALSE;
  local
    var integer: upTo is 0;
    var integer: testNum is 3;
  begin
    if number = 2 then
      prime := TRUE;
    elsif odd(number) and number > 2 then
      upTo := sqrt(number);
      while number rem testNum <> 0 and testNum <= upTo do
        testNum +:= 2;
      end while;
      prime := testNum > upTo;
    end if;
  end func;
 
const func integer: digitSum (in var integer: number) is func
  result
    var integer: sum is 0;
  begin
    while number > 0 do
      sum +:= number rem 10;
      number := number div 10;
    end while;
  end func;
 
const proc: main is func
  local
    var integer: n is 0;
    var integer: count is 0;
  begin
    for n range 2 to 499 do
      if isPrime(n) and isPrime(digitSum(n)) then
        write(n lpad 3 <& " ");
        incr(count);
        if count rem 9 = 0 then
          writeln;
        end if;
      end if;
    end for;
    writeln("\nFound " <& count <& " additive primes < 500.");
  end func;