Efficient Algorithm for Calculating (n^x)/d

  • Thread starter Thread starter Atran
  • Start date Start date
AI Thread Summary
The discussion presents an efficient algorithm for calculating (n^x)/d using a recursive approach. It demonstrates the process with an example where n=46, x=5, and d=13, breaking down the division into manageable components. The algorithm utilizes the quotient and remainder from the division to simplify the calculations for higher powers of n. The method emphasizes a structured recursive formula to handle the exponentiation and division efficiently. Overall, the algorithm aims to optimize the computation of (n^x)/d for large values of n and x.
Atran
Messages
93
Reaction score
1
Hi, I've recently found the following algorithm and I'm willing to share it:

For example, given an integer n=46, an exponent x=5, and d=13, we have 465/13.
First, we set the equation, n = q*d + r = q*13 + r
We have, 46 = 3*13 + 7
Thus, [q=3, r=7, d=13]
And: 465/13 = 3*464 + 7*(3*463 + 7*(3*462 + 7*(3*461 + 7*(46/13))))

Let [q, r, d] and we have (n^4)/d, then:
(n^4)/d = q*n^(4-1) + r*(q*n^(4-2) + r*(q*n^(4-3) + r*(n/d)))

I don't know if it's interesting to you or not, but what are your thoughts about it?
 
Mathematics news on Phys.org
Perhaps you'll get more comments if you write the expression in a less computationally efficient manner.

\frac{(qd + r)^5}{d} = q(qd+r)^4 + rq(qd+r)^3 + r^2q(qd+r)^2 + r^3q(qd+r) + r^4\frac{(qd+r)}{d}
 
Insights auto threads is broken atm, so I'm manually creating these for new Insight articles. In Dirac’s Principles of Quantum Mechanics published in 1930 he introduced a “convenient notation” he referred to as a “delta function” which he treated as a continuum analog to the discrete Kronecker delta. The Kronecker delta is simply the indexed components of the identity operator in matrix algebra Source: https://www.physicsforums.com/insights/what-exactly-is-diracs-delta-function/ by...
Suppose ,instead of the usual x,y coordinate system with an I basis vector along the x -axis and a corresponding j basis vector along the y-axis we instead have a different pair of basis vectors ,call them e and f along their respective axes. I have seen that this is an important subject in maths My question is what physical applications does such a model apply to? I am asking here because I have devoted quite a lot of time in the past to understanding convectors and the dual...

Similar threads

Back
Top