Factorial is: 120 Explanation:In the above program, we created two functions factorial() and main(). The factorial() function is a recursive function, which is used to calculate the factorial of the given number.In the main() function, we called the factorial() function and printed the ...
In the above program, we created two functions getFactorial(), main(). The getFactorial() function is used to find the factorial of the given number and return the result to the calling function.In the main() function, we read the values of n and r. Then we calculate the nPr with ...
The output is always a single number.Python allows the calculation of the dot product of two arrays, provided the length-sequences of both the arrays are similar.Use the * Sign to Calculate the Dot Product of Two Scalars in PythonThe scalars are also known as 0-dimensional arrays and are...
Area of Circle using Java Program //Java program to Calculate Area of a Circle.importjava.util.Scanner;publicclassAreaCircle{publicstaticvoidmain(String[]args){doubleradius;Scanner sc=newScanner(System.in);// input radius of circleSystem.out.print("Enter the Radius of Circle : ");radius=sc....
Enter number2: 13 Product is: 156 Explanation In the above program, we imported the "java.util.*" package to use the Scanner class. Here, we created a public classMain. TheMainclass contains two static methodscalculateProduct(),main(). ThecalculateProduct()is a recursive method that finds...
Enter number1: 100 Enter number2: 40 Highest Common Factor is:20 Explanation: In the above program, we declare the packagemain. Themainpackage is used to tell the Go language compiler that the package must be compiled and produced the executable file. Here, we imported thefmtpackage that in...
// Scala program to calculate the// power of a numberobjectSample{defmain(args:Array[String]):Unit={varnum:Int=0;varp:Int=0;varres:Double=0;print("Enter number: ")num=scala.io.StdIn.readInt()print("Enter power: ")p=scala.io.StdIn.readInt()res=scala.math.pow(num,p)println("Resul...
Golang goto Statement Example – Calculate the power of a given number Problem Solution: In this program, we will read an integer number and its power from the user and then calculate the power of a given number and print the result on the console screen. ...
// Rust program to calculate the product// of two numbers using recursionfncalculateProduct(a:i32, b:i32)->i32{ifa<b {returncalculateProduct(b, a); }elseifb!=0{return(a+calculateProduct(a, b-1)); }else{return0; } }fnmain() {leta:i32=6;letb:i32=8;letres=calculateProduct(a, ...
C Program to Calculate the Value of nPr Below is the C program to calculate the value of nPr: // C program to calculate the value of nPr #include<stdio.h> // Function to calculate the factorial of a number intfactorial(intnum) { if (num<=1) { return1; } returnnum*factorial(num-...