Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created February 7, 2022 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/279d1bd80b7c9445e35b4e3bc115ca25 to your computer and use it in GitHub Desktop.
Save parzibyte/279d1bd80b7c9445e35b4e3bc115ca25 to your computer and use it in GitHub Desktop.
using System;
namespace ParImpar
{
class Program
{
static void Main(string[] args)
{
// https://parzibyte.me/blog
Console.WriteLine("Escribe un número: ");
long numero = Convert.ToInt64(Console.ReadLine());
long sobrante = numero % 2;
if (sobrante == 0)
{
Console.WriteLine("El número es par");
}
else
{
Console.WriteLine("El número es impar");
}
SinModulo();
}
static void SinModulo()
{
Console.WriteLine("Escribe un número: ");
long numero = Convert.ToInt64(Console.ReadLine());
long sobrante = numero & 1;
if (sobrante == 0)
{
Console.WriteLine("El número es par");
}
else
{
Console.WriteLine("El número es impar");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment