By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,062 Members | 1,358 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,062 IT Pros & Developers. It's quick & easy.

Need some logic to do math with factorials

P: 1
this question i cant answer it maybe you will laugh but i cant
the question is:
1/1!+2/2!+3/3!+4/4!+5/5!+6/6!
i want the answer in visual basic language please i am waiting for reply
Sep 22 '07 #1
Share this Question
Share on Google+
4 Replies


YarrOfDoom
Expert 100+
P: 1,247
I don't have visual studio here, so I can't give you guaranteed bug-free code but this should do it:
Expand|Select|Wrap|Line Numbers
  1. function double nFacultities()
  2. Dim result as double, finalresult as double, nfacultity as integer, current as integer
  3. nfacultity = 0
  4. finalresult = 0
  5. For current = 1 to 6
  6.      nfacultity = nfacultity * current
  7.      result = current / nfacultity
  8.      finalresult = finalresult + result
  9. next current
  10. nFacultities = finalresult
  11. return nFaculties
  12. end function
  13.  
Yarr Of Doom
Sep 22 '07 #2

Expert 5K+
P: 8,434
Let me see if I can remember any maths... does the "!" indicate factorial? As in all the numbers up to there multipled together?
Sep 22 '07 #3

YarrOfDoom
Expert 100+
P: 1,247
Let me see if I can remember any maths... does the "!" indicate factorial? As in all the numbers up to there multipled together?
I suppose it is, I used some badly translated term from Dutch :P

Yarr Of Doom
Sep 23 '07 #4

Expert 5K+
P: 8,434
Fair enough. At a glance, I think the code you already posted will do the trick.

I should warn you, lothario, that I've written a function previously to calculate factorials, and they become unmanageably large very quickly.
Sep 23 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.