| | |
Calculate the factorial of a number
![]() |
could you possibly post the code you have so we can tell exactly what you need help with. that would make it easier to help up thanks
I haven't coded in QBasic in years, but in VB it would be like the following:
"lngFactorial" would then be your number. Is this what you're looking for?
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Dim intNumber As Integer Dim lngFactorial As Long Dim lngCounter As Long intNumber = 5 For lngCounter = 1 To intNumber lngFactorial = lngFactorial * lngCounter Next lngCounter
"lngFactorial" would then be your number. Is this what you're looking for?
•
•
Join Date: Apr 2004
Posts: 7
Reputation:
Solved Threads: 0
If you do not use logarithmus, you will be getting overflow error for factorial of integers larger then approx. 280.
This is VB6 code:
Dim l As Long
Dim res As Double
For l = 1 To total
res = res + Log(CDbl(l))
Next
The final result "res" is used for furhter mathematical operation, rather then directly printing its value val= Exp(res), since if val is too high, you would just get the overflow error.
This is VB6 code:
Dim l As Long
Dim res As Double
For l = 1 To total
res = res + Log(CDbl(l))
Next
The final result "res" is used for furhter mathematical operation, rather then directly printing its value val= Exp(res), since if val is too high, you would just get the overflow error.
![]() |
Similar Threads
- How do I calculate the closest number to a number? (C)
- Calculating a factorial of a number using C# (C#)
- Code Snippet: finding factorial of a number. (C)
- Beginner in Java: need a help (Java)
- Factorial of a number (C)
- program for finding factorial of a number using *operator overloading (C++)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Preprocessor directives
- Next Thread: HELP with VB project
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





