Thursday, February 5, 2026
HomeLanguagesJavascriptp5.js exp() Method

p5.js exp() Method

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() {
  
    // Create Canvas of size 270*80
    createCanvas(600, 300);
}
  
function draw() {
      
    // Set the background color
    background(220);
      
    // Initialize the parameter and
    // return the value of the function
    let n = exp(1.1)
    let m = exp(3.3)
      
    // Set the size of text
    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() {
  
    // Create Canvas of size 270*80
    createCanvas(600, 500);
}
  
function draw() {
    let x, m;
    let step = 50
     
    // Set the background color
    background(220);
  
    // Initialize the parameter and return
    // the value of the function
    // For loop is set from numbers 0 to 10.
    for( x = 0; x <= 10; x++) {
          
        // The return value of exp() function
        m = exp(x)
        text( "Result for " + x +
             ": " + m, 50, step);
       
        step = step + 30;
      }
      
      // Set the size of text
      textSize(17);
      
      // Set the text color
      fill(color('blue'));
}


Output: Reference: https://p5js.org/reference/#/p5/exp

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

2 COMMENTS

Most Popular

Dominic
32489 POSTS0 COMMENTS
Milvus
126 POSTS0 COMMENTS
Nango Kala
6861 POSTS0 COMMENTS
Nicole Veronica
11983 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12073 POSTS0 COMMENTS
Shaida Kate Naidoo
6995 POSTS0 COMMENTS
Ted Musemwa
7235 POSTS0 COMMENTS
Thapelo Manthata
6946 POSTS0 COMMENTS
Umr Jansen
6929 POSTS0 COMMENTS