using System;
public class Program
{
public static void Main(String[] args)
{
Console.WriteLine( NumberUtils.IsEven(0) ); // true // even
Console.WriteLine( NumberUtils.IsEven(1) ); // false
Console.WriteLine( NumberUtils.IsEven(2) ); // true // even
Console.WriteLine( NumberUtils.IsEven(3) ); // false
Console.WriteLine( NumberUtils.IsEven(4) ); // true // even
Console.WriteLine( NumberUtils.IsEven(5) ); // false
Console.WriteLine( NumberUtils.IsEven(-1) ); // false
Console.WriteLine( NumberUtils.IsEven(-2) ); // true // even
Console.WriteLine( NumberUtils.IsEven(-3) ); // false
Console.WriteLine( NumberUtils.IsEven(-4) ); // true // even
Console.WriteLine( NumberUtils.IsEven(-5) ); // false
}
}
public class NumberUtils
{
public static bool IsEven(int number)
{
return (number & 1) == 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