FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaScript/Maths/ExponentialFunction.js at master · Jerad551/JavaScript · GitHub
Jerad551
/
JavaScript
Public
forked from
TheAlgorithms/JavaScript
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaScript
/
Maths
/
ExponentialFunction.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
25 lines (24 loc) · 651 Bytes
Breadcrumbs
JavaScript
/
Maths
/
ExponentialFunction.js
Copy path
File metadata and controls
25 lines (24 loc) · 651 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/**
*
@function
exponentialFunction
*
@description
Calculates the n+1 th order Taylor series approximation of exponential function e^x given n
*
@param
{
Integer
} power
*
@param
{
Integer
} order - 1
*
@returns
exponentialFunction(2,20) = 7.3890560989301735
*
@url
https://en.wikipedia.org/wiki/Exponential_function
*/
function
exponentialFunction
(
power
,
n
)
{
let
output
=
0
let
fac
=
1
if
(
isNaN
(
power
)
||
isNaN
(
n
)
||
n
<
0
)
{
throw
new
TypeError
(
'Invalid Input'
)
}
if
(
n
===
0
)
{
return
1
}
for
(
let
i
=
0
;
i
<
n
;
i
++
)
{
output
+=
power
**
i
/
fac
fac
*=
i
+
1
}
return
output
}
export
{
exponentialFunction
}
Back
|
FazBrowse Home
|
New Git URL