using System; public class Program { public static void Main(String[] args) { Console.WriteLine( NumberUtils.IsOdd(0) ); // false Console.WriteLine( NumberUtils.IsOdd(1) ); // true // odd Console.WriteLine( NumberUtils.IsOdd(2) ); // false Console.WriteLine( NumberUtils.IsOdd(3) ); // true // odd Console.WriteLine( NumberUtils.IsOdd(4) ); // false Console.WriteLine( NumberUtils.IsOdd(5) ); // true // odd Console.WriteLine( NumberUtils.IsOdd(-1) ); // true // odd Console.WriteLine( NumberUtils.IsOdd(-2) ); // false Console.WriteLine( NumberUtils.IsOdd(-3) ); // true // odd Console.WriteLine( NumberUtils.IsOdd(-4) ); // false Console.WriteLine( NumberUtils.IsOdd(-5) ); // true // odd } } public class NumberUtils { public static bool IsOdd(int number) { return number % 2 != 0; } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter