Found 7197 Articles for C++

Number of triangles in a plane if no more than two points are collinear

Simran Kumari
Updated on 23-Mar-2023 14:35:32

269 Views

Let us see how to calculate the number of triangles in a plane with n number of points given, with the constraint that not more than two points are collinear. Computing the number of triangles in a plane with no more than two collinear points is a typical problem in computational geometry, and it is used in computer graphics, image processing, and other areas of computer science. While creating a 2D image from a 3D scene in 3D graphics, for instance, the issue of counting triangles in a plane with no more than two points collinear can come up. The ... Read More

Different ways to represent N as the sum of K non-zero integers

Simran Kumari
Updated on 23-Mar-2023 14:31:37

786 Views

The problem “Different ways to represent N as the sum of K non-zero integers” has many real-world use cases. Cryptography − In cryptography, specific cryptographic methods are designed using the concept of encoding a number N as the sum of K non-zero integers. Representing an integer N as the sum of K non-zero integers might appear as a subproblem in different optimization issues in the context of optimization methods. Machine learning − In machine learning, feature vectors that depict the distribution of data points can be created by using the problem of representing an integer N as the sum of ... Read More

Vieta’s Formulas

Rinish Patidar
Updated on 16-Mar-2023 11:01:17

5K+ Views

In mathematics, Vieta’s formulas are the concept of polynomials which relates a polynomial’s coefficients to the sums and products of the roots of the polynomial. Vieta’s formulas can be useful tools for learning relations between the polynomial’s roots without really knowing their numerical value and coefficients of the equation. We will be focusing on the concept of Vieta’s formulas and try to solve some problems using this formula in this article. Vieta’s Formulas The formulas developed by the mathematician Vieta establish the relationship between the sum and product of any polynomial’s roots and its coefficients. Since this formula deals with ... Read More

Subsequence of size k with maximum possible GCD

Rinish Patidar
Updated on 16-Mar-2023 10:58:17

877 Views

The problem statement says we will be given an array as input and a positive integer K, we need to figure out the maximum possible gcd(greatest common divisor) of a ksized subsequence of an array in this problem. It can be solved using different algorithms to find gcd of the numbers and figuring out the maximum gcd for a k-sized subsequence. Before that we must know about the subsequence of an array. A subsequence of an array is a sequence of numbers from the array not necessarily adjacent numbers in the array but the order of the numbers in the ... Read More

Smarandache-Wellin Sequence

Rinish Patidar
Updated on 16-Mar-2023 10:55:17

370 Views

The problem includes printing first m terms of Smarandache-Wellin Sequence where m is any positive integer. We will see the algorithm to print the first m term of Smarandache-Wellin Sequence in C++. But before that we must know about the Smarandache-Wellin sequence. A Smarandache-Wellin sequence is a sequence of Smarandache-Wellin numbers. Smarandache-Wellin numbers are the integers which are formed by concatenation of the consecutive prime numbers. The first few prime numbers are 2, 3, 5, 7, 11, 13, 17, 19, 23…. The first Smarandache-Wellin number of the sequence is 2. The second number of the sequence is 23, which ... Read More

Program to compare m^n and n^m

Rinish Patidar
Updated on 16-Mar-2023 10:53:12

351 Views

The problem statement states that we need to write a program to compare m^n and n^m. We need to figure out the algorithm to calculate $m^{n}$ and $n^{m}$ and compare them and print accordingly if $m^{n}$ is greater than $n^{m}$, or if $m^{n}$ is less than $n^{m}$ , or if they both are equal. We will be given two positive numbers, m and n and we need to find out $m^{n}$ and $n^{m}$ and compare both the values. For example, INPUT : m=2 , n=5 OUTPUT : m^n is greater than n^m. Explanation : $m^{n}$ which is 25 = 32 ... Read More

Heptagonal number

Rinish Patidar
Updated on 16-Mar-2023 10:47:04

465 Views

A heptagonal number is a number which can be represented as a heptagon. A heptagon is a polygon with 7 sides. A heptagonal number can be represented as a combination of successive layers of heptagon( 7-sided polygon). Heptagonal number can be better explained with the below figures. The first heptagonal number is 1. Thus, it can be represented by a single dot. The second heptagonal number is 7 which can be represented by a heptagon. The third heptagonal number is 18 which can be represented as a heptagon and combined with a successive layer of heptagon. ... Read More

Find the GCD that lies in given range

Rinish Patidar
Updated on 16-Mar-2023 10:25:14

649 Views

The problem states that we need to find the GCD that lies in the given range. We will be given two positive integers, x and y and two integers p and q which will be the range as [p, q]. We need to find out the GCD (greatest common divisor) of the numbers x and y falling under the range [p, q]. GCD, known as greatest common divisor in mathematics, is the greatest positive integer dividing each of two given positive integers. The given integers must not be zero. It is represented as gcd(x, y) for any two positive integers ... Read More

Check whether a given number is Polydivisible or Not

Rinish Patidar
Updated on 16-Mar-2023 10:22:33

422 Views

The problem statement includes checking whether a given number is Polydivisible or not for any given integer N. A polydivisible number, also known as magic number, is a number following a unique pattern. The number created by first p digits of the given number should always be divisible by p and there should not be any leading zeros in the given number. If a number satisfies these properties, it is a Polydivisible number, else it is not. Here, p should be in range (1, total digits in the given number). Let’s understand the concept of polydivisible number with an example: ... Read More

Check if the n-th term is odd or even in a Fibonacci like sequence

Rinish Patidar
Updated on 16-Mar-2023 10:18:26

380 Views

Our task in this problem is to check if the n-th term of a fibonacci like sequence is odd or even. A fibonacci sequence is a type of sequence in mathematics where each number in the sequence is the sum of the preceding two numbers. A nth term of the fibonacci sequence can be represented as − $$\mathrm{Fn\:=\:F_{n-1}\:+\:F_{n-2}}$$ The first few numbers of the fibonacci sequence are 0, 1, 1, 2, 3, 5, 8, 13, 21, 34….. The first two numbers of the sequence are 0 and 1. The next numbers are the sum of the preceding two ... Read More

Advertisements