Factorial in PHP Simple Program1

factorial in php
PHP

Factorial in PHP Simple Program1

Write a program to find the factorial in php of a number.

Factorial of a number is the product of numbers from 1 to ‘n’.

Eg:- 5! = 1*2*3*4*5 = 120

PHP :-

<?php
$n = 10;
$product = 1;

for($i=1; $i<=$n; $i++)
{
    $product = $product*$i;
}
echo 'The factorial of '.$n.' is '.$product;
?>
  1. Declare the number to $n
  2. Set $product as 1
  3. In a for loop, loop through 1 to $n
  4. Inside the for loop, multiply $i with $product
  5. Print the result after closing loop

For more information visit gmp_fact.

For more php related queries visit PHP

85 thoughts on “Factorial in PHP Simple Program1

  1. I loᴠed аs much as you’ll receive carrіеd out right here.
    The sketch is attractive, ʏour authored subject matter stylish.
    nonethelеss, you command get bought an impatience over tuat
    you wish be delijvering the following. unwell unquestionably
    come further formerly again since exаctly the sаme nearly very оften іnside case
    you shield this hike.

    my web site :: 먹튀사이트

  2. Hello! Quick question that’s totally off topic.
    Do you know how to make your site mobile friendly?

    My web site looks weird when browsing from my iphone4. I’m trying to find a template or plugin that might be able to resolve this problem.

    If you have any suggestions, please share. Many
    thanks!

  3. What i don’t realize is if truth be told how you are no longer actually much more
    neatly-appreciated than you might be now. You’re so intelligent.
    You understand thus significantly in the case of this topic,
    made me in my view imagine it from so many numerous
    angles. Its like men and women aren’t involved until it’s something to accomplish with
    Woman gaga! Your individual stuffs excellent. At all times care for it up!

  4. Every weekend i used to pay a quick visit this web site, as i wish for
    enjoyment, for the reason that this this website conations really nice funny data too.

  5. Hello! This is kind of off topic but I need some guidance from an established blog.

    Is it hard to set up your own blog? I’m not very techincal but I can figure things out pretty fast.
    I’m thinking about making my own but I’m not sure where
    to start. Do you have any tips or suggestions?
    Appreciate it

  6. Hi thеre! I just wanted to ask if you ever have any problems witһ hackers?
    My last bloց (ԝordpress) ԝas hackked and I ended up losing months of hard work due to no backup.

    Do you have any methods to prоtect against hackers?

    Cheсk oᥙt my weƄ page; situs domino qq

  7. Hello There. I found your blog the use of msn. That is a really smartly written article.
    I will be sure to bookmark it and return to learn extra of your helpful
    information. Thank you for the post. I will certainly return.

  8. Have you ever thought about including a little bit more than just
    your articles? I mean, what you say is important and everything.

    But think about if you added some great visuals or video clips to give your posts more,
    “pop”! Your content is excellent but with pics and
    clips, this blog could definitely be one of the most beneficial
    in its niche. Excellent blog! https://wiki-aero.win/index.php?title=Nfl_Predictions_2008_-_2009_916314542&oldid=519489 https://wiki-planet.win/index.php?title=Nfl_Jerseys_For_Infants_996284040&oldid=566106 https://source-wiki.win/index.php?title=2011_Nfl_Draft_-_New_Players_216333138&oldid=537021

    Review my web-site; accessibility click here

  9. Hey there, I think your site might be having browser compatibility issues.
    When I look at your blog in Safari, it looks fine but when opening in Internet Explorer, it has some overlapping.
    I just wanted to give you a quick heads up! Other then that,
    great blog!quality assurance as a verb (Annett)http://qrzpwfjavhvhhh73.mee.nu/?entry=3372972http://elizaxt.mee.nu/?entry=3360537

  10. Please let me know if you’re looking for a writer for your
    weblog. You have some really great articles and I feel I would be
    a good asset. If you ever want to take some of
    the load off, I’d really like to write some material for your
    blog in exchange for a link back to mine. Please send me an e-mail
    if interested. Thank you!

  11. Excellent blog here! Also your website loads up fast!

    What web host are you using? Can I get your affiliate link to your
    host? I wish my website loaded up as fast as yours lol

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top