Link Search Menu Expand Document

Challenge: Calculate (a + b)^3

Problem Statement #

The task is to compute (a+b)3(a + b)^3(a+b)​3​​ and display it on the console. The following mathematical formula is expanded as:

(a+b)​3​​=a​3​​+b​3​​+3ab(a+b)

Sample Input


a = 2
b = 2

Output

64

Coding Exercise

It is recommended​ that you try solving the exercise yourself before viewing the solution.

Important Note: The power of xyx^yx​y​​ is calculated as datatype :: pow(x,y). Here, the data type is the return value of the power function.

 fn test() {
    let a = 2;
    let b = 2;
    // Write code here!
}

Good luck!🤞