Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- // 1 2 3 are primes
- int numPrimes = 3;
- for (int num = 4; num < 65535; num++)
- {
- if (IsPrime(num)) { Console.WriteLine(num + " is a prime number."); numPrimes++; }
- }
- Console.WriteLine("there were " + numPrimes + " primes.");
- Console.ReadKey();
- }
- static bool IsPrime(int value)
- {
- for (int i = 2; i < value - 1; i++) if (value % i == 0) return false;
- return true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement