p5.js exp() Method
Last Updated :
25 Jan, 2023
The exp() function returns the value of n (any number) to the Euler’s number e(2.71828…) raised to the power n (e^n).
Syntax:
exp(n)
Parameters: This method accepts a single parameters n i.e. the number value.
Return Value: It returns (e^n) of the given number.
Example 1:
Javascript
function setup() {
createCanvas(600, 300);
}
function draw() {
background(220);
let n = exp(1.1)
let m = exp(3.3)
textSize(16);
text( "Result in Eular number will be :" + n, 50, 50);
text( "Result in Eular number will be :" + m, 50, 80);
}
|
Output: Example 2:
Javascript
function setup() {
createCanvas(600, 500);
}
function draw() {
let x, m;
let step = 50
background(220);
for ( x = 0; x <= 10; x++) {
m = exp(x)
text( "Result for " + x +
": " + m, 50, step);
step = step + 30;
}
textSize(17);
fill(color( 'blue' ));
}
|
Output: Reference: https://p5js.org/reference/#/p5/exp
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...