- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Create a procedure to find out the factorial of a number?
It can be created with the help of the following query −
mysql> Delimiter // mysql> CREATE PROCEDURE fact(IN x INT) -> BEGIN -> DECLARE result INT; -> DECLARE i INT; -> SET result = 1; -> SET i = 1; -> WHILE i <= x DO -> SET result = result * i; -> SET i = i + 1; -> END WHILE; -> SELECT x AS Number, result as Factorial; -> END// Query OK, 0 rows affected (0.17 sec)
Now when invoking this procedure by passing the value of which we want to get the factorial as an argument −
mysql> Delimiter ; mysql> CALL Fact(5); +--------+-----------+ | Number | Factorial | +--------+-----------+ | 5 | 120 | +--------+-----------+ 1 row in set (0.00 sec) Query OK, 0 rows affected (0.00 sec) mysql> CALL Fact(6); +--------+-----------+ | Number | Factorial | +--------+-----------+ | 6 | 720 | +--------+-----------+ 1 row in set (0.00 sec) Query OK, 0 rows affected (0.00 sec)
- Related Articles
- 8085 program to find the factorial of a number
- 8086 program to find the factorial of a number
- How can we create MySQL stored procedure to calculate the factorial?
- Java Program to Find Factorial of a number
- Swift Program to Find Factorial of a number
- Kotlin Program to Find Factorial of a number
- How to Find the Factorial of a Number using Python?
- How to find the Factorial of a number in Golang?
- Haskell Program To Find The Factorial Of A Positive Number
- Python program to find factorial of a large number
- Python Program to find the factorial of a number without recursion
- C++ Program to Find Factorial of a Number using Iteration
- C++ Program to Find Factorial of a Number using Recursion
- Java Program to Find Factorial of a Number Using Recursion
- Java program to find the factorial of a given number using recursion

Advertisements