Programming Articles - Page 580 of 3363

Python Program to calculate the logarithm gamma of the given number

Alekhya Nagulavancha
Updated on 14-Oct-2022 08:30:21

780 Views

In mathematics, the gamma function is said to be an extension to the factorial of any given number. However, as the factorial is only defined for real numbers, the gamma function exceeds to define the factorial on all complex numbers except the negative integers. It is represented by − Γ(x) = (x-1)! The logarithm gamma function comes into picture as the gamma function grows rapidly only larger numbers, so applying logarithm to the gamma will slow it down a lot. It is also known as the natural logarithm gamma of a given number. log(Γ(x)) = log((x-1)!) In python ... Read More

Python Program to calculate the volume and area of the Cylinder

Alekhya Nagulavancha
Updated on 14-Oct-2022 08:05:51

3K+ Views

In this article, we will look into a python program to calculate the volume and area of a cylinder. A cylinder is defined as a 3D object that has two circles connected with a rectangular surface. The special thing about a cylinder is that even though it is measured using just two dimensions, i.e. the height and radius, the cylinder is considered a three-dimensional figure as it is measured in xyz coordinate axes. The area of the cylinder is calculated is two ways− area of the lateral surface and area of the total surface. Lateral surface area is only the ... Read More

Python Program to calculate the volume of Cube

Alekhya Nagulavancha
Updated on 14-Oct-2022 07:57:45

7K+ Views

A cube is a three-dimensional solid figure with six faces, twelve edges and eight vertices. This geometrical figure has equal sized edges, hence making all its dimensions − length, width and height − equal. The idea of calculating the volume of a cube can be understood in a simple way. Consider a real-time situation where a person a moving houses. Suppose they use a hollow cube shaped cardboard box to place their things in it, the amount of space present to fill it up is defined as the volume. The mathematical formula to calculate the volume of a cube ... Read More

Python Program to calculate the area of Cube

Alekhya Nagulavancha
Updated on 14-Oct-2022 07:52:57

4K+ Views

To calculate the area of a cube, let us first revise the concept of a cube. A cube is a geometrical figure containing three dimensions: length, width, and height with all the dimensions having equal measurements. It has six square faces, four of which are lateral surfaces and the other two are the cube's top and bottom surfaces. The requirement to find the surface area is just knowing the length a single edge. The area of a cube is found using the following steps − Find the area of one square face with the given edge Four times ... Read More

Kotlin Program to Generate Multiplication Table

AmitDiwan
Updated on 13-Oct-2022 13:39:41

1K+ Views

In this article, we will understand how to print a multiplication table. Multiplication table is created by iterating the required input 10 times using a for loop and multiplying the input value with numbers from 1 to 10 in each iteration. Below is a demonstration of the same − Suppose our input is − Input : 16 The desired output would be − The multiplication table of 16 is : 16 * 1 = 16 16 * 2 = 32 16 * 3 = 48 16 * 4 = 64 16 * 5 = 80 16 * 6 = ... Read More

Kotlin Program to Round a Number to n Decimal Places

AmitDiwan
Updated on 13-Oct-2022 13:38:07

2K+ Views

In this article, we will understand how to round a number to n decimal places. Rounding of decimal values are done using the ceil() or floor() functions. Below is a demonstration of the same − Suppose our input is Input : 3.1415 The desired output would be − Output : 3.2 Algorithm Step 1 − START Step 2 − Declare a float value namely myInput. Step 3 − Define the values Step 4 − Use format() to alter the number of decimal places required. Store the result. Step 5 − Display the result Step 6 − Stop ... Read More

Kotlin Program to calculate Simple Interest and Compound Interest

AmitDiwan
Updated on 13-Oct-2022 13:33:15

968 Views

In this article, we will input the Principal Amount, Rate and Time (Years) from the user to find the Simple Interest and Compound Interest − Simple Interest − The percentage interest on total principal amount. Returns are less compared to Compound Interest. Compound Interest − The percentage interest charged on principal and accrued interest. Rates are higher compared to Simple Interest. Below is a demonstration of the same − Suppose our input is − Principal = 25000.0 Annual Rate of Interest = 10.0 Time (years) = 4.0 The desired output would be − Simple Interest: 10000.0 Compound ... Read More

Kotlin Program to Count the Number of Vowels and Consonants in a Sentence

AmitDiwan
Updated on 13-Oct-2022 13:25:27

963 Views

In this article, we will understand how to count the vowels and consonants in Kotlin. Alphabets that include the following are called Vowels − ‘a’ ‘e’ ‘i’ ‘o’ ‘u’ All other alphabets are called Consonants. Suppose our input is − Hello, my name is Charlie The desired output would be − The number of vowels in the statement is: 8 The number of vowels in the Consonants is: 12 Algorithm Step 1 − Start Step 2 − Declare two integers: vowelsCount, consonantsCount and a string input Step 3 − Define the values Step 4 − Run ... Read More

Kotlin Program to Sort Elements in Lexicographical Order (Dictionary Order)

AmitDiwan
Updated on 13-Oct-2022 13:27:29

445 Views

In this article, we will understand how to sort the elements of an array in Lexicographical order in Kotlin. The lexicographical order is a generalization of the alphabetical order of the dictionaries to sequences. Below is a demonstration of the same − Suppose our input is − Alpha Beta Gamma Delta The desired output would be − Delta Gamma Beta Alpha Algorithm Step 1 − Start Step 2 − Declare three integers: I, j and temp Step 3 − Declare a string array myInput Step 4 − Run a for-loop, using the swap method, arrange the words ... Read More

Kotlin Program to Calculate the Sum of Natural Numbers

AmitDiwan
Updated on 13-Oct-2022 13:15:53

779 Views

In this article, we will understand how to calculate the sum of natural numbers in Kotlin. All possible positive numbers from 1 to infinity are called natural numbers. Below is a demonstration of the same − Suppose our input is 1 and 100 The desired output would be − Sum of natural numbers from 1 to 100 is 3825 Algorithm Step 1 − Start Step 2 − Declare an integers input Step 3 − Define the integers Step 4 − Run a for-loop, add the number with its next number until the upper limit is reached. Store ... Read More

Advertisements