How to find 'n' raise to power 'n' in java -
i trying find efficient way calculating n^n in java. result large large n, used biginteger result data type , n integer. if n becomes large n=10000000 takes more time calculate result. there efficient way calculate within second.
handle log of number, n ln(n)
, in program. n
grows, size of n ln(n)
relative n^n
shrinks faster , faster.
the way implement depends on need do. if don’t need n^n
inside program, forget , on paper once program outputs. when you’re handling numbers big, log/order of magnitude/the number of digits has (all of synonymous) of essential information. if program outputs x
, report answer around e^x
, , say.
if need n^n
inside program, should still calculate x = ln(n^n) = n ln(n)
. you’re going have come creative way of going x
value program can use.
Comments
Post a Comment