Holooly Plus Logo

Input / Question:

Input / Question:

Write a program using a loop that takes one value n from the user and shows the factorial of all prime numbers that are less then n, for example if n = 10 then the program will print the factorial of 2, 3, 5 and 7.

Verified

Output/Answer

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

namespace Problem23

{

classProblem23

{

staticvoid Main(string[] args)

{

Console.WriteLine("\t\tName: Ehtesham Mehmood\n\t\tRoll No: 11014119-131\n\t\tSection: AE\n \t\t UOG\n");

int j;

int num;

int fact=1;

Console.WriteLine("Enter The Number:");

num = Convert.ToInt32(Console.ReadLine());

 

for (int i = 1; i <= num; i++)

{

 

for (j = 2; j <i; j++)

{

 

 

 

if (i % j == 0)

{

 

 

goto outloop;

 

}

 

}

outloop:

if (j == i)

{

fact = 1;

for(int k=1;k<=i;k++)

{

fact=fact*k;

}

Console.WriteLine("Factorial Of "+i+" Prime Number Is "+fact);

}

//if (i == 0 || i == 1)

//{

// Console.WriteLine("Entered Number Is Not A Composite Number Nor A Prime Number.");

//}

}

Console.ReadKey();

}

}

 

}

Output: