Flowchart (ISO 5807)
Source code
C++
void sieve(int n) {
bool prime[100];
for (int i = 0; i <= n; i++) prime[i] = true;
for (int p = 2; p * p <= n; p++) {
if (prime[p]) {
for (int i = p * p; i <= n; i += p) prime[i] = false;
}
}
for (int i = 2; i <= n; i++) {
if (prime[i]) cout << i << " ";
}
}The editor opens with this code — change it and the chart redraws.
- Language
- C++
- Constructs
- primes up to n
- Topic
- Algorithms
- Formats
- Word, Visio, draw.io, PDF, SVG