how do I do factorial?

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
paranova9
Newbie
Posts: 17
Joined: Wed Jul 29, 2009 9:19 pm

how do I do factorial?

Post by paranova9 » Tue Sep 07, 2010 4:11 am

how do I do factorial?

paranova9
Newbie
Posts: 17
Joined: Wed Jul 29, 2009 9:19 pm

Post by paranova9 » Tue Sep 07, 2010 4:23 am

as in for example, how do I script:

4!

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Tue Sep 07, 2010 8:05 am

Hi paranova9,

A quick search of these forums for: factorial

http://www.mjtnet.com/forum/viewtopic.p ... =factorial

...found the post at the above link. You'll find a way to do it there.

Take care
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

paranova9
Newbie
Posts: 17
Joined: Wed Jul 29, 2009 9:19 pm

Post by paranova9 » Wed Sep 08, 2010 8:42 am

i saw that page b4 I posted, tried it, couldn't get it to work. no bother though, i wrote my own subroutine to do the job. still just hoping there is an easier way. seems quite strange to need to do all this for a fairly common mathematical function

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Wed Sep 08, 2010 6:05 pm

Hi paranova9,
paranova9 wrote:i saw that page b4 I posted, tried it, couldn't get it to work. no bother though, i wrote my own subroutine to do the job.
Great to hear you wrote your own that worked... and I take it its just MS code without VBScript?

Could you please post it here in case others might have a similar need?

Thanks and take care
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Wed Sep 08, 2010 9:50 pm

i saw that page b4 I posted, tried it, couldn't get it to work
Try this. It should work for you.

Code: Select all

VBSTART
  function factorial(N)
  if N = 0 then
    factorial = 1
    exit function
  end if
  factorial = N * factorial(N-1)
end function
VBEND

VBEval>factorial(5),fac

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts