## VBA

Moderators: PavlinII
Number of posts: 3000

This Forum Only

Getting Factorial of 666 in VB Posted by rizwan1217 on 26 Aug 2003 at 6:36 AM
HI... my basic problem is
B = (A^n/n!) / (A^1/1!+A^2/2!+A^3/3!---------+A^n/n!)
where B and n is given and i have to find the A factor.(i will use Newton Raphson Farmula to calculate it ) but problem i m facing is if the value of n is greater than java support then it overflows the stack by recursion of function plz help me ......
i dont say all the help but anything u know about this problem :) will be enough for me
Re: Getting Factorial of 666 in VB Posted by Psightoplazm on 13 Sept 2003 at 1:38 PM
You said that you are getting overflow in N?
Have you tried allocating more memory to your variables?
Or if you are saying that you are just getting an overflow on your stack, then you are going to have to find a way to break your code down into more than one line. Work in smaller steps and sometimes you can handle larger numbers.

I've run into that problem once and I had to split my equation into a high order and low order ends. This can be really hard to do in your head, but if you stick in a couple extra steps, the high end can be cut out by like /100000 and the low end would be the difference. Then the multiplicative distribution law applies to both the high order and low order, and anything like the additive distribution law would only apply to the order that it deals with. Then any overflow from the low order end can be handled by your code and transfered to the high order end.

></\/~Psightoplasm`~

Re: Getting Factorial of 666 in VB Posted by rizwan1217 on 15 Sept 2003 at 8:33 AM
: You said that you are getting overflow in N?
: Have you tried allocating more memory to your variables?
: Or if you are saying that you are just getting an overflow on your stack, then you are going to have to find a way to break your code down into more than one line. Work in smaller steps and sometimes you can handle larger numbers.
:
: I've run into that problem once and I had to split my equation into a high order and low order ends. This can be really hard to do in your head, but if you stick in a couple extra steps, the high end can be cut out by like /100000 and the low end would be the difference. Then the multiplicative distribution law applies to both the high order and low order, and anything like the additive distribution law would only apply to the order that it deals with. Then any overflow from the low order end can be handled by your code and transfered to the high order end.
:
:
: ></\/~Psightoplasm`~
:
:
my equation is B = A^n/n!/(A^1/1!+A^2/2!+A^3/3!+------+A^n/n!)
in the most simplest form of this equation i need to get the factorial of 666! and A^666
i m worry becaz i have to submit it at 12th of next month

VB Solution Posted by didani on 16 Sept 2003 at 7:25 AM
: : You said that you are getting overflow in N?
: : Have you tried allocating more memory to your variables?
: : Or if you are saying that you are just getting an overflow on your stack, then you are going to have to find a way to break your code down into more than one line. Work in smaller steps and sometimes you can handle larger numbers.
: :
: : I've run into that problem once and I had to split my equation into a high order and low order ends. This can be really hard to do in your head, but if you stick in a couple extra steps, the high end can be cut out by like /100000 and the low end would be the difference. Then the multiplicative distribution law applies to both the high order and low order, and anything like the additive distribution law would only apply to the order that it deals with. Then any overflow from the low order end can be handled by your code and transfered to the high order end.
: :
: :
: : ></\/~Psightoplasm`~
: :
: :
: my equation is B = A^n/n!/(A^1/1!+A^2/2!+A^3/3!+------+A^n/n!)
: in the most simplest form of this equation i need to get the factorial of 666! and A^666
: i m worry becaz i have to submit it at 12th of next month
:
:
:
If you are scripting in java, why place a message in this board.
anywayz, this is my solution for VB:

dim c, d as long

Public Sub Factorial(a as long, n as long)
c = a^n/n!
d = 0
for i = 1 to n
d = d + ( a / i / i! )
next i
b = c / d
msgbox b
End Sub

let me know if it worx...

EtHeO out...

## Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic