Skip to content

Commit

Permalink
Erastofen algoritm task (#2)
Browse files Browse the repository at this point in the history
* Erastofen Grid

* Erastofen upgradet

* Erastofen app CPP language
  • Loading branch information
vasilukwolf committed Jul 31, 2020
1 parent cec2955 commit 796b6a2
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Eratosfen/Erastofen.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <iostream>
using namespace std;
int main()
{
int n;
cout << "n= ";
cin >> n;
int *a = new int[n + 1];
for (int i = 0; i < n + 1; i++)
a[i] = i;
for (int p = 2; p < n + 1; p++)
{
if (a[p] != 0)
{
cout << a[p] << endl;
for (int j = p*p; j < n + 1; j += p)
a[j] = 0;
}
}
cin.get(); cin.get();
}

0 comments on commit 796b6a2

Please sign in to comment.