using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace function
{
Class Program
{
static void main(string[] args)
{
Class Program
{
static void main(string[] args)
{
prime_comp();
factorial();
odd_even();
}
static public void odd_even()
{
int n;
Console.WriteLine("Input any number.");
n= Convert.ToInt32(Console.ReadLine());
if (n%2==0)
{
Console.WriteLine("The number is even.");
}
else
{
Console.WriteLine("The number is odd.");
}
Console.ReadLine();
}
static public void factorial()
{
int n, i, fact = 1;
Consol.WriteLine("Input any number."):
n = Convert.ToInt32(Console.ReadLine()):
for(n==0)
{
Console.WriteLine("The factorial of 0 is 1");
}
else{
for(i=1; i<=n; i++)
{
fact = fact * i;
}
Console.WriteLine("The factorial of given number is: {0}",fact);
}
}
static public void prime_comp()
{
int num, flag = 0;
Console.WriteLine("Input any number.");
num = Convert.ToInt32(Console.ReadLine());
for(int i=2; i<num; i++)
{
if (num %i == 0)
{
Console.WriteLine("The number is composite");
flag = 1;
breal'
}
}
if (flag == 0)
{
Console.WriteLine(" The number is prime");
}
Console.ReadLine();
}
}
}
OUTPUT:
Input any number.
7
The number is prime
Input any number.
8
The given number is even.
Input any number.
7
The fatorial of given number is: 5040
Comments
Post a Comment