22 #ifndef GEARS_MATH_GENERATOR_HPP 
   23 #define GEARS_MATH_GENERATOR_HPP 
   28 #include "algorithm.hpp" 
   46 template<
typename Container, 
typename Value = 
typename Container::value_type>
 
   47 inline void primes(Value limit, Container& cont) {
 
   51     Value offset = limit % 6 > 1;
 
   52     Value wheels[6] = { limit, limit - 1, limit + 4, limit + 3, limit + 2, limit + 1 };
 
   54     Value n = wheels[limit % 6];
 
   55     std::vector<bool> sieve(n / 3, 
true);
 
   57     for(Value i = 0, upper = static_cast<Value>(std::sqrt(n))/3; i <= upper; ++i) {
 
   60             for(Value j = (k * k) / 3; j < n / 3; j += 2 * k) {
 
   64             for(Value j = (k * k + 4 * k - 2 * k * (i & 1)) / 3; j < n / 3; j += 2 * k) {
 
   70     for(Value i = 1; i < n / 3 - offset; ++i) {
 
   72             cont.push_back((3 * i + 1) | 1);
 
   91 template<
typename Container, 
typename Integral>
 
   93     for(Integral i = 1; i < limit; ++i) {
 
   94         if((i * i + (i + 1) * (i + 1)) > limit) {
 
   98         for(Integral j = i + 1; j < limit; j += 2) {
 
   99             if(j * j + i * i > limit) {
 
  107             cont.emplace_back(j * j - i * i, 2 * i * j, i * i + j * j);
 
  114 #endif // GEARS_MATH_GENERATOR_HPP