Hub Of Geekz

  • Home
  • About Me
  • Contact Us
  • Home
  • Languages
    • C++
    • Java
    • Perl
    • Prolog
    • Bootstrap
  • Database
    • SQL
    • PL/SQL
  • Study
    • Java
      • Java Collection
      • Java Concurrency
      • Java Interview Questions
      • Java Networking
    • Number System
  • Kavita
  • Entertainment
    • Hinglish Cafe
    • Videos
    • Jokes
  • Windows Tricks
  • How To

Sunday, 28 April 2013

Write a program in PL/SQL to print the factorial of a number.

 Earthcare Foundation NGO     22:42     PL/SQL     3 comments   

In this post I will explain how to get the factorial of any given number. For that first you need to know what is the procedure to find the factorial of a number.
To get the factorial of any given number we have to multiply that number to every number less than that number till 1.
Suppose we have to find the factorial of 5. Then,
factorial(5)=5*4*3*2*1
                  =120
So in this way we can calculate the factorial of any number.
If you want to know the procedure to find the Fibonacci Sequence Click Here

Program Code:
SQL> set serveroutput on
SQL> declare
  2  i number(5);
  3  j number (5);
  4  f number(10);
  5  begin
  6  i:=&i;
  7  f:=1;
  8  for j in 1..i
  9  loop
 10  f:=f*j;
 11  end loop;
 12  dbms_output.put_line(f);
 13  end;
 14  .
SQL> /

Output:

Enter value for i: 3
old   6: i:=&i;
new   6: i:=3;
6

PL/SQL procedure successfully completed.

Enter value for i: 5
old   6: i:=&i;
new   6: i:=5;
120



Result: Thus the above program to print the factorial of a number was executed successfully.

So above is a simple program how to find Factorial of any given number. If there is any query regarding anything please comment.



Thanks


You might be interested in

PL/SQL Basics
Cursor in PL/SQL
Triggers in PL/SQL
Create process in PL/SQL
PL/SQL program to find Greatest

PL/SQL program to get the area of circle
PL/SQL program to print different patterns
PL/SQL program to print Fibonacci Sequence
PL/SQL program to perform mathematical operations

  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Email ThisBlogThis!Share to XShare to Facebook
Newer Post Older Post Home

3 comments:

  1. Anonymous17 March 2015 at 23:42

    thank you for the program:)
    was of great use to me;

    ReplyDelete
    Replies
      Reply
  2. Unknown2 May 2015 at 09:33

    You are welcome

    ReplyDelete
    Replies
      Reply
  3. sumit kumar gupta16 June 2018 at 08:43

    Thank you for sharing this program is very helpful for me

    ReplyDelete
    Replies
      Reply
Add comment
Load more...

Ad


Jobsmag.inIndian Education BlogThingsGuide

Subscribe

Do you want fresh and hot updates about us? Then subscribe to our Feeds.

Total Pageviews

Popular Posts

  • Write a program in PL/SQL to print the factorial of a number.
    In this post I will explain how to get the factorial of any given number. For that first you need to know what is the procedure to find ...
  • To find the GCD of two numbers in PROLOG.
    gcd(X,Y):-X=Y,write('GCD of two numbers is '),write(X); X=0,write('GCD of two numbers is '),write(Y); Y=0,write('G...
  • Write a PL/SQL code to get the Fibonacci Sequence
    First, I will explain what is Fibonacci Sequence and how to get this series. So, Fibonacci Sequence is a series of numbers 0,1,1,2,3,5,8,1...

Label

All Articles Best Resources Blogging Boost Traffic Bootstrap C Plus Plus Collection Comedy Comedy Posts Comedy Videos Concurrency creative commons website Education Employee Entertainment Fibonacci Sequence free images GirlFriend Hinglish Cafe How To Image Websites Inspirational Java Java Interview Questions Java Networking Kavita Sangrah Life Lock Sreen Love Number System Patterns Perl Picture PL/SQL Plastic Engineering Programming Prolog public domain SEO Servlet Short Story Shortcut Keys Social Media Social Services SQL SuVichar Thread Traffic True Events Ultimate Guide Windows Tricks Windows8.1 WordPress

Blog Archive

  • ►  2020 (43)
    • ►  September (41)
    • ►  August (2)
  • ►  2019 (1)
    • ►  July (1)
  • ►  2018 (9)
    • ►  September (7)
    • ►  July (1)
    • ►  May (1)
  • ►  2017 (8)
    • ►  June (3)
    • ►  May (3)
    • ►  March (1)
    • ►  January (1)
  • ►  2016 (2)
    • ►  September (1)
    • ►  January (1)
  • ►  2015 (91)
    • ►  December (1)
    • ►  November (1)
    • ►  October (6)
    • ►  May (10)
    • ►  March (20)
    • ►  February (50)
    • ►  January (3)
  • ►  2014 (339)
    • ►  December (1)
    • ►  October (55)
    • ►  September (58)
    • ►  August (94)
    • ►  July (64)
    • ►  June (67)
  • ▼  2013 (34)
    • ►  August (5)
    • ▼  April (29)
      • Write a PL/SQL code to find the greatest number am...
      • Write a PL/SQL code to create and use process.
      • Write a PL/SQL code to get the Fibonacci Sequence
      • Write a PL/SQL code to implement after row trigger.
      • Write a PL/SQL code to calculate total sal of emp ...
      • Cursor in PL/SQL.
      • Write a program in PL/SQL to print the following p...
      • Write a program in PL/SQL to print the factorial o...
      • To calculate the areas of circles of given radius ...
      • To perform mathematical operation of two numbers u...
      • To perform the string function in simple database ...
      • To perform the numeric function in simple database...
      • To perform logical operations in simple database t...
      • To perform the group function in simple database T...
      • To create the simple relationship between two tabl...
      • To create a set of operation in simple database ta...
      • To alter table of a simple database using CREATE,A...
      • To create a database table using Create, Desc, Ins...
      • To write program in PROLOG to implement Tower in ...
      • To find the sum of given list in PROLOG
      • To create relations in PROLOG
      • To find the largest of three numbers in PROLOG.
      • To find the largest of three numbers in PROLOG.
      • To find the larger of two numbers in PROLOG.
      • To find the GCD of two numbers in PROLOG.
      • To find the factorial of given number in PROLOG.
      • To count the number of elements in a list in PROLOG.
      • To construct a binary tree in PROLOG
      • To perform arithmetic operations in PROLOG
  • ►  2012 (20)
    • ►  November (1)
    • ►  October (15)
    • ►  September (4)

Author

  • Earthcare Foundation NGO
  • Kavita house
  • Unknown
  • Unknown

Info

Copyright © Hub Of Geekz | Powered by Blogger
Design by Hardeep Asrani | Blogger Theme by NewBloggerThemes.com | Distributed By Gooyaabi Templates