Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Numerics;
- namespace _04b_MethodsDebuggingTroubleshootingCode_Exercises
- {
- class MethodsDebuggingTroubleshootingCode_Exercises
- {
- static void Main(string[] args)
- {
- long num = long.Parse(Console.ReadLine());
- Console.WriteLine(ReturnisPrime(num));
- }
- static bool ReturnisPrime(long num)
- {
- num = Math.Abs(num);
- if (num == 0) return false;
- if (num == 1) return false;
- if (num == 2) return true;
- for (long i = 2; i <= Math.Ceiling(Math.Sqrt(num)); ++i)
- {
- if (num % i == 0) return false;
- }
- return true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment