# 10!

## Recommended Posts

I use 4 Function to calculate this topic,only For Loop got wrong ~

While Loop ✓

```\$sum = sum(10)
Msgbox(0,"Total","Total:"&\$sum)
Func sum(\$x)
\$loop = 1
\$y = 10
While \$loop
\$y = \$y - 1
\$x = \$x * \$y
If \$y == 1 Then \$loop = 0
WEnd
Return \$x
EndFunc```

Recursion ✓

```\$sum = sum(10)
Msgbox(0,"Total","Total:"&\$sum)
Func sum(\$x)
If \$x = 1 Then
Return 1
Else
Return \$x * sum(\$x - 1)
EndIf
EndFunc```

Do Loop ✓

```\$sum = sum(10)
Msgbox(0,"Total","Total:"&\$sum)
Func sum(\$x)
\$y = 10
Do
\$y = \$y - 1
\$x = \$x * \$y
Until \$y == 1
Return \$x
EndFunc```

For Loop ✖

```\$sum = sum(10)
Msgbox(0,"Total","Total:"&\$sum)
Func sum(\$x)
\$y = 10
For \$i = 10 To 1 Step - 1
\$y = \$y - 1
\$x = \$x * \$y
Next
Return \$x
EndFunc```

##### Share on other sites

Change line

`For \$i = 10 To 1 Step -1`
to
`For \$i = 10 To 2 Step -1`
Because if you go down to 1 and then subtract 1 you multiply with 0. Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version 1.6.2.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

##### Share on other sites

```\$sum = sum(10)
MsgBox(0, "Total", "Total:" & \$sum)
Func sum(\$x)
\$y = 10
For \$i = 10 To 1 Step -1
\$y -= 1
\$x += \$x * \$y
Next
Return \$x
EndFunc ;==>sum```

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

##### Share on other sites

```#include <Constants.au3>

Local \$iValue = Factorial(10)
MsgBox(\$MB_SYSTEMMODAL, '', 'Total: ' & \$iValue)

Func Factorial(\$x)
Local \$y = \$x
For \$i = 1 To \$y - 1
\$x *= \$i
Next
Return \$x
EndFunc   ;==>Factorial```

Edited by guinness

##### Share on other sites

Thanks for the tutorial~ I got it!!!

##### Share on other sites

I think I learnt something too, though I won't let you know what!

##### Share on other sites

Not to be pedantic, but your function should be called "factorial()", not "sum()".

Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

##### Share on other sites

Why I love 52!

So how many ways can you order all the 52 cards in a pack?

The sum is 52x51x50x49x48....x4x3x2x1 and the answer is roughly:

80,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000

That's an 8 with 67 zeros after it.

To put this in perspective, the dinosaurs died out 65,000,000 years ago, and the age of the earth is just 4,500,000,000 years. Now suppose everybody in the world was to arrange packs of cards at the rate of one per second, it would take 600,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000 years to get all the combinations! That's why you're VERY unlikely ever to shuffle a pack of cards the same way twice.

##### Share on other sites

52! = 80658175170943878571660636856403766975289505440883277824000000000000

(a LOT more!)

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

##### Share on other sites

True, I'd love 1% of 1‰ of 1‱ of the absolute value of the difference, even in ¥.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...