AYUSH MISHRA

AYUSH MISHRA

112 Articles Published

Articles by AYUSH MISHRA

Page 8 of 12

Python Program for Sum of first N even numbers

AYUSH MISHRA
AYUSH MISHRA
Updated on 17-Mar-2025 5K+ Views

The sum of the first N even numbers is a mathematical operation. In this operation, we add up the firstN even numbers. In Python, there are multiple ways to calculate this sum. In this article, we are going to learn and discuss various approaches to finding the sum of the first N even numbers in Python. Finding the Sum of the First N Even Numbers The formula for finding the sum of the first N even numbers is: Sum = N * (N + 1) Example 1Let's look at a scenario where N=5, The first 5 even numbers ...

Read More

Python Program to find area of square

AYUSH MISHRA
AYUSH MISHRA
Updated on 25-Feb-2025 21K+ Views

A square is a closed two-dimensional figure having 4 equal sides. Each angle of a square is 90 degrees. The area of a square is the space enclosed within its four sides. In this problem, we are given the side of a square, and we have to find the area of the square. In this tutorial, we are going to find the area of a given square in Python using different approaches. Example 1 Input: side = 6 units Output: 36 square units Using the formula to calculate the area of the square: side × side = 6 × ...

Read More

Python Program to Calculate nCr and nPr

AYUSH MISHRA
AYUSH MISHRA
Updated on 05-Feb-2025 11K+ Views

In combinatorics, nCr and nPr are essential formulas used to calculate combinations and permutations. They represent the number of ways to select and arrange objects from a set. nCr refers to combinations, where order does not matter, while nPr refers to permutations, where order does matter. The permutation refers to the arrangement of objects in a specific order.A combination refers to the selection of objects without taking order in reference. In this article, we are going to learn how we can calculate nCr and nPr in Python using different approaches. The formula for nCr and nPr The formulas ...

Read More

Python Program to Find Average of Array Elements

AYUSH MISHRA
AYUSH MISHRA
Updated on 04-Feb-2025 9K+ Views

In this article, we will learn how to find the average of array elements using Python, along with examples to demonstrate the implementation. In this problem, we are given an array of integers, which may contain both positive and negative numbers. Our task is to calculate the average of all elements in the array. Using the Brute Force Approach This is a simple and direct approach. This approach involves manually iterating through each element in the array to calculate the sum. Then, we divide the total sum by the count of elements to get the average. This approach is ...

Read More

Python Program to Toggle Each Character in a String

AYUSH MISHRA
AYUSH MISHRA
Updated on 04-Feb-2025 12K+ Views

In this problem, we are given a string, and the task is to toggle the case of each character in the string. This means that all lowercase letters should be converted to uppercase, and all uppercase letters should be converted to lowercase. In this article, we are going to explore different approaches to toggling each character in a string using Python. Let's look at the simple example, where we are going to provide input as "TutorialsPoint". Then output is like "tUTORIALSpOINT" In this case each character is toggled. Such that Uppercase letters become lowercase and lowercase becomes uppercase. Below are ...

Read More

Python Program for sum of the series: 1 + 1/2 + 1/3 + ... + 1/n

AYUSH MISHRA
AYUSH MISHRA
Updated on 04-Feb-2025 14K+ Views

Mathematical series is one of the problems that helps us to improve problem-solving and logical thinking skills One of the engaging problems is calculating the sum of the harmonic series. The series 1 + 1/2 + 1/3 + ⋯⋯ + 1/n is known as the harmonic series. In this article, we are going to learn how to find the sum of the series: 1 + 1/2 + 1/3 + ⋯⋯ + 1/n using Python. What is the Harmonic Series? The harmonic series is a mathematical sequence where each term is the reciprocal of a positive integer. It is represented as, ...

Read More

Python Program to Implement Ternary Search

AYUSH MISHRA
AYUSH MISHRA
Updated on 04-Feb-2025 10K+ Views

Searching is one of the most fundamental operations in computer science, and there are multiple algorithms to perform it efficiently. While Binary Search is mainly known to be applied to sorted array searching, Ternary Search is another efficient searching technique that also works on sorted arrays for searching. What is a Ternary Search Ternary Search is a divide-and-conquer algorithm that splits the array into three parts instead of two (as in Binary Search). It repeatedly reduces the search space by two-thirds in each step, making it useful in cases where the dataset is large, and constant-time comparisons are expensive. ...

Read More

Java Program to Find the Volume of Cylinder

AYUSH MISHRA
AYUSH MISHRA
Updated on 04-Feb-2025 17K+ Views

A cylinder is a three-dimensional geometric shape with two parallel circular bases connected by a curved surface. The volume of a cylinder can be calculated using a mathematical formula that considers its radius and height. Problem Description In this tutorial, we are going to discuss how to find the volume of a given cylinder in Java using different approaches. Formula for Volume of Cylinder The formula for the volume of a cylinder is as follows: Volume of Cylinder = π × r² × h where: r: The radius of the circular base. h: The height of the cylindrical body. ...

Read More

Python Program to Find Cube of a Number

AYUSH MISHRA
AYUSH MISHRA
Updated on 31-Jan-2025 6K+ Views

The Cube of a number is a simple mathematical operation where a number is multiplied by itself three times. In Python, there are multiple ways to find the cube of a number. In this article, we are going to discuss various approaches to calculating the cube of a number in Python. How to find cube of a number? The formula for finding the cube of a given number N is: Cube = N × N × N or N3 Example 1 Input: 5 Output: 125 Explanation: The cube of ...

Read More

C++ Program for Absolute Sum of Array Elements

C++
AYUSH MISHRA
AYUSH MISHRA
Updated on 31-Jan-2025 6K+ Views

In this problem, we are given an array of integers, and our task is to calculate the absolute sum of its elements. The absolute sum means the sum of the absolute values of all the array elements. In this article, we are going to learn how to compute the absolute sum of an array's elements using C++. Example 1 Input: arr = {-3, 2, -7, 4} Output: 16 Explanation: The absolute values of the array elements are: | -3 | = 3, | 2 | = 2, | -7 | = 7, | 4 | = 4. The sum of ...

Read More
Showing 71–80 of 112 articles
« Prev 1 6 7 8 9 10 12 Next »
Advertisements