Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Main(string[] args)
- {
- // Write an expression that checks if given positive integer number n (n = 100) is prime (i.e. it is divisible without remainder only to itself and 1).
- int n = 0;
- do
- {
- Console.WriteLine("Input a positive integer:");
- n = int.Parse(Console.ReadLine());
- }
- while (n <= 1);
- bool prime = true;
- if ((n % n == 0) && (n % 1 == 0))
- {
- Console.WriteLine(prime);
- }
- else
- {
- Console.WriteLine(!prime);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement