Число называется простым, если оно делится на само себя и на 1 без остатка.
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101
Main.cs
usingSystem;classProgram {-
publicstaticintMain() { -
Console.Write("Введите конец диапазона от 2 до : "); -
intend=int.Parse(Console.ReadLine()); -
for(inti=2; i<=end; i++) { -
boolb=true; -
for(intj=2; j<i; j++) { -
if(i%j==0 & i%1==0) { -
b=false; -
} -
} -
if(b) { -
Console.Write("{0} ", i); -
} -
} -
Console.ReadKey(); -
return0; -
} }
usingSystem;classProgram {-
publicstaticintMain() { -
Console.Write("Введите конец диапазона от 2 до : "); -
intend=int.Parse(Console.ReadLine()); -
for(inti=2; i<=end; i++) { -
boolb=true; -
for(intj=2; j<i; j++) { -
if(i%j==0 & i%1==0) { -
b=false; -
} -
} -
if(b) { -
Console.Write("{0} ", i); -
} -
} -
Console.ReadKey(); -
return0; -
} }
Введите конец диапазона от 2 до : 50
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47