Untitled
unknown
plain_text
3 years ago
991 B
5
Indexable
using System; using System.Collections; using System.Text; using System.Text.RegularExpressions; namespace ConsoleApp8 { class Program { // function of bài 7 public static bool isPrime(int n) { if (n < 2) return false; int square = (int)Math.Sqrt(n); for (int i = 2; i <= square; i++) { if (n % i == 0) return false; } return true; } static void Main(string[] args) { //bài 7 Console.Write("nhap n: "); int n = Int32.Parse(Console.ReadLine()); int count = 0; int i = 2; while (count < n) { if (isPrime(i)) { Console.Write(i + " "); count++; } i++; } } } }
Editor is loading...