Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Prime Number
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.Reflection; using System.Text; namespace Rextester { public class Program { public static void Main(string[] args) { //Your code goes here Int32 inu = 1; try { if(IsPrimeNo(inu)) Console.WriteLine("Number "+inu.ToString()+" is not Prime."); else Console.WriteLine("Number "+inu.ToString()+" is Prime."); } catch(Exception ex) { Console.WriteLine("Error occured while running job. Error is" + ex.Message ); } } static bool IsPrimeNo(int iNu ) { try { int IDm = 0; IDm = iNu/2; bool iBl = false; for(int i=2; i <= IDm; i++) { if(iNu % i > 0) { iBl = false; } else { iBl = true; break; } } return iBl; } catch(Exception ex) { throw; } } } }
run
|
edit
|
history
|
help
0
Classes
VB6 DateSerial to C#
C
Area of a field
Where To Watch The Bad Guys (2022) Free online at Home
Fibonacci Series
delete_xml_empty_tags
ElaineBrown
aaa
Fórum regex only alphanumerics (except underscore)