Hafeezul Kareem has Published 328 Articles

Largest number less than N with digit sum greater than the digit sum of N in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 13:32:49

377 Views

In this tutorial, we are going to write a program that finds the number less than N with digit sum greater than the digit sum of n.Let's see the steps to solve the problem.Write a function to find the digits sum.Initialise n.Write a loop that iterates from n - 1 ... Read More

Largest N digit number divisible by given three numbers in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 13:29:56

286 Views

In this tutorial, we are going to write a program that finds the largest n-digit number that is divisible by the given three numbers.Let's see the steps to solve the problem.Initialise three numbers along with n.Find the LCM of three numbers.Store the largest number with n-digits.If the largest number is ... Read More

Largest K digit number divisible by X in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 13:29:35

172 Views

In this tutorial, we are going to write a program that finds the largest k-digit number that is divisible by x.Let's see the steps to solve the problem.Initialise the x and k.Find the value of pow(10, k) - 1 which is largest k-digit number.Now, remove the remainder value from the ... Read More

Largest even number possible by using one swap operation in given number in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 13:21:14

719 Views

In this tutorial, we are going to write a program that finds the largest possible even number with a single swap of digits.Let's see the steps to solve the problem.Initialise the number in string format.Iterate over the given number.Find the even digit that is less than or equal to the ... Read More

Largest even digit number not greater than N in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 13:20:05

177 Views

In this tutorial, we are going to write a program that finds the largest number whose digits are all even and not greater than the given n.Let's see the steps to solve the problem.Initialise the number n.Write a loop from i = n .Check whether the digits of current number ... Read More

Largest Even and Odd N-digit numbers in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 13:19:28

510 Views

In this tutorial, we are going to write a program that finds the largest even and odd number of n digits number.Let's see the steps to solve the problem.Initialise the number n.The largest odd number is pow(10, n) - 1.The largest even number is odd - 1.ExampleLet's see the code. Live ... Read More

Larger of a^b or b^a in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 13:18:53

314 Views

In this tutorial, we are going to write a program that finds out the larger among the ab and baIt's a straightforward problem. Let's see the steps to solve it.Initialise the values of a and b.Take the log of both the values.Compute the values of $b\:\log\:a$ and $a\:\log\:b$Compare the both ... Read More

Lagrange’s Interpolation in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 13:16:03

2K+ Views

In this tutorial, we are going to write a program that finds the result for lagranges's interpolation formula.You don't have write any logic for the program. Just convert the formula into code. Let's see the code.Example Live Demo#include using namespace std; struct Data {    int x, y; }; double interpolate(Data ... Read More

Lagrange’s four square theorem in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 13:11:26

396 Views

In this tutorial, we are going to learn about largrange's four square theorem.The lagranges's four square theorem states that every natural number can be written as sum of squares of 4 numbers.The following code finds the 4 numbers which satisfies the above condition for the given number n.ExampleLet's see the ... Read More

kth smallest/largest in a small range unsorted array in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 13:10:55

128 Views

In this tutorial, we are going to write a program that finds the k-th smallest number in the unsorted array.Let's see the steps to solve the problem.Initialise the array and k.Sort the array using sort method.Return the value from the array with the index k - 1.Let's see the code.Example Live ... Read More

Advertisements