Getting Factorial of 666 in VB - Programmers Heaven

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# Getting Factorial of 666 in VB

Posts: 88Member
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

• Posts: 332Member ✭✭
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`~

• Posts: 88Member
: 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

• Posts: 99Member
: : 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...