Strong and weak primes: Difference between revisions
m
C++ - made function definitions out of line
(Added Swift solution) |
m (C++ - made function definitions out of line) |
||
Line 317:
public:
explicit prime_info(int max) : max_print(max) {}
void add_prime(int prime);
void
++count2;▼
if (prime < limit1)▼
++count1;▼
if (count2 <= max_print) {▼
if (count2 > 1)▼
out << ' ';▼
out << prime;▼
}▼
void print(std::ostream& os, const char* name) const {▼
os << "First " << max_print << " " << name << " primes: " << out.str() << '\n';▼
os << "Number of " << name << " primes below " << limit1 << ": " << count1 << '\n';▼
os << "Number of " << name << " primes below " << limit2 << ": " << count2 << '\n';▼
private:
int max_print;
Line 340 ⟶ 325:
std::ostringstream out;
};
void prime_info::add_prime(int prime) {
}
}
int main() {
|