Calculate the Factorial of a Number Using Recursion in Python Calculate the Factorial of a Number Using themath.factorial()Function in Python Afactorialof a number is a product of all positive integers less than or equal to that number. For example, the factorial of 5 is the product of all...
Below is the JavaScript program to calculate the value of nPr: // JavaScript program to calculate the value of nPr // Function to calculate the factorial of a number functionfactorial(num){ if (num<=1) { return1; } returnnum*factorial(num-1); } // Function to calculate the value of ...
Python Program to Find Armstrong Number in an Interval Python Program to Check Armstrong Number Python Program to Find the Factorial of a Number Python Program to Print the Fibonacci sequence Python Program to Find the Largest Among Three Numbers Python Program to Display the multiplication Table Pyt...
In the above program, we created two functionsgetFactorial(),main(). ThegetFactorial()function is used to find the factorial of the given number and return the result to the calling function. In themain()function, we read the values ofnandr. Then we calculate thenPrwith the help of the...
// Golang program to calculate the power of a // given number using the goto statement package main import "fmt" func main() { var num int = 0 var power int = 0 var result int = 1 fmt.Print("Enter Number: ") fmt.Scanf("%d", &num) fmt.Print("Enter Power: ") fmt.Scanf...
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...
Enter number1: 12 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...
// 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...
In the above code, we created a global variable sum with the initial value 0, and we implemented a recursive function SumOfDigits() that accepts a number and returns the sum of all digits to the calling function.In the main() function, we read an integer number from the user ...
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...