int find_number(int x = 20)
{
  if (is_divisible_by(x, 20))
    return x;
  else if (x < 1000000000)
    return find_number(x+1);
  else
    return 0;
}
bool is_divisible_by(int val, int x)
{
  if (x > 2 && val % x == 0)
    return is_divisible_by(val, x-1);
  else if (x == 2)
    return true;
  else
    return false;
}
Exemple #3
0
void calculate_next()
{
  uint part= expected_part, num= expected_num;
  uint no_parts= tot_no_parts;
  if (max_ind)
  {
    do
    {
      while (++part <= no_parts)
      {
        if (is_divisible_by(num, part) &&
            (num <= ((1 << 21) + part)))
        {
          expected_part= part;
          expected_num= num;
          return;
        }
      }
      part= 0;
    } while (--num);
  }
  else
  {
    do
    {
      while (--part > 0)
      {
        if (is_divisible_by(num, part))
        {
          expected_part= part;
          expected_num= num;
          return;
        }
      }
      part= no_parts + 1;
    } while (++num);
  }
}