November 24, 2020, 09:28:28 AM

Author Topic: [bb] ! (Factorial) Finder by Lattyware [ 1+ years ago ]  (Read 515 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] ! (Factorial) Finder by Lattyware [ 1+ years ago ]
« on: June 29, 2017, 12:28:41 AM »
Title : ! (Factorial) Finder
Author : Lattyware
Posted : 1+ years ago

Description : This finds n!
<a href="http://www.cut-the-knot.org/do_you_know/permutation.shtml" target="_blank">http://www.cut-the-knot.org/do_you_know/permutation.shtml[/url] tells you more about what a factorial is.

Basically 5! is 5*4*3*2(*1)

Simple but does the job.


Code :
Code: BlitzBasic
  1. Print Fact%(0)
  2.  
  3. WaitKey()
  4. End
  5.  
  6. Function Fact%(Num)
  7.  
  8. Perms = Num
  9.  
  10. For a = 1 To Num - 1
  11.  
  12. Perms = Perms * (Num - a)
  13.  
  14. Next
  15.  
  16. If Num = 0 Then
  17.         Return 1
  18. Else
  19.         Return Perms
  20. EndIf
  21. End Function


Comments :


Kevin_(Posted 1+ years ago)

 <a href="codearcse2c0.html?code=1297" target="_blank">http://www.blitzbasic.com/codearcs/codearcs.php?code=1297[/url]


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal