Witam, moglibyście mi przerobić program z c++ na c#? Będę bardzo wdzięczny :)
#include <iostream>
#include <math.h>
using namespace std;
void sito(int n)
{
bool *tab = new bool[n + 1];
for(int i = 0; i <= n; i++)
tab[i] = true;
int zakres = floor(sqrt((float)n));
for(int i = 2; i <= zakres; i++){
if(tab[i]){
int j = i + i;
while(j <= n){
tab[j] = false;
j += i;
}
}
}
for(int i = 2; i <= n; i++){
if(tab[i])
cout << i << " ";
}
delete tab;
}
int main()
{
int n;
cout << "Podaj zakres: ";
cin >> n;
cout << "Liczby pierwsze od 2 do " << n << ":" << endl;
sito(n);
return EXIT_SUCCESS;
}