How to write C# factorial programm in ui path studio

class Program

  1. {

  2.    static void Main(string[] args)
  3.    {
  4.        int i, number, fact;
  5.        Console.WriteLine("Enter the Number");
  6.        number = int.Parse(Console.ReadLine());
  7.        fact = number;
  8.        for (i = number - 1; i >= 1; i--)
  9.        {
  10.            fact = fact * i;
  11.        }
  12.        Console.WriteLine("\nFactorial of Given Number is: "+fact);
  13.        Console.ReadLine();
  14.    }
  15. }

@sri123ui: Welcome to the UiPath community, I would encourage you to go thru the foundations course in the Academy which would enable you to write any program that you want and give you a better perspective to achieve your goals in UiPath.

Once you take the course you will be amazed over the endless possibilities to assist business cases that will benefit from it.

Also, I would like to point out that this post is a question, on how to do a program which will be categorized on the How to section. Please check the community before posting questions that way we can reduce redundancy. Ideas categories will contain improvements or your suggestions you would like to see in UiPath.

Happy automating!

1 Like

Hi @sri123ui,

you can follow the same steps in the uipath its self using activities.
Refer this link

create 3 integer variable

For this one you can use input dialog activity to get input at the run time.

use for each activity

use assign activity

For showing final output use message box or log message activity to get the output.


You can use a lambda to convert the numbers to a list then multiple them.

x = 5
Enumerable.Range(1,x).ToList.Aggregate(Function(a,b) a*b).ToString

I used a Message box to check the result.

1 Like

Thank u bro, i want xaml file

Hi @sri123ui,
Refer this xaml file.

Factorial.xaml (13.7 KB)


thank u bro

using System;

namespace ConsoleApplication1
class Program
static void Main(string args)
int number;

        Console.WriteLine("Please enter a number between 0 and 10:");
        number = int.Parse(Console.ReadLine());

        if(number > 10)
            Console.WriteLine("Hey! The number should be 10 or less!");
            if(number < 0)
                Console.WriteLine("Hey! The number should be 0 or more!");
                Console.WriteLine("Good job!");



can u send xaml files for this program