Found 33676 Articles for Programming

Count of numbers from range[L, R] whose sum of digits is Y in C++

Sunidhi Bansal
Updated on 31-Oct-2020 04:57:09

305 Views

We are provided two numbers START and END to define a range of numbers.The goal is to find all the numbers in the range [START, END] which have sum of digits equal to a given number Y.We will do this by traversing numbers from START to END and for each number we will count the sum of its digit using a while loop. If this sum is equal to Y, increment count.Let’s understand with examples.Input START=10 END=20 Y=4Output Numbers such that digit sum is equal to Y: 1Explanation Number 13 has digit sum equal to 4.Input START=10 END=50 Y=5Output Numbers such that digit sum is ... Read More

Count of common multiples of two numbers in a range in C++

Sunidhi Bansal
Updated on 31-Oct-2020 04:55:08

2K+ Views

We are given two numbers A and B. Also provided two numbers START and END to define a range of numbers. The Ath tile has paint white and Bth tile has paint black. If the tile is painted both black and white then it turns grey. The goal is to find the total number of grey tiles .We will do this by traversing numbers from START to END and for each number we will check if the number is multiple of both A and B. If yes increment count.Let’s understand with examples.Input START=10 END=20 A=3 B=6Output Common multiples of A and B ... Read More

Count numbers with difference between number and its digit sum greater than specific value in C++

Sunidhi Bansal
Updated on 31-Oct-2020 04:53:26

614 Views

We are provided two numbers N which defines a range [1, N] and D which is a difference.The goal is to find all the numbers in the range [1, N] such that the [ number - (sum of its digits) ] > D. We will do this by traversing numbers from 1 to N and for each number we will calculate its digit sum using a while loop. Check if the number and calculated digit sum has a difference more than D.Let’s understand with examples.Input N=15 D=5Output Numbers such that difference b/w no. and its digit sum greater than value D: 6Explanation Numbers ... Read More

Count numbers in range that are divisible by all of its non-zero digits in C++

Sunidhi Bansal
Updated on 31-Oct-2020 04:50:25

234 Views

We are provided two numbers START and END to define a range of numbers.The goal is to find all the numbers in the range [START, END] that are divisible by all of its non-zero digits . We will do this by traversing numbers from START to END and for each number we will check if the number is divisible by all non-zero digits using a while loop. If yes increment count.Let’s understand with examples.Input START=10 END=20Output Numbers that are divisible by all its non-zero digits: 14Explanation Numbers 10, 11, 12, 15, 20 are divisible by all their non-zero digits.Input START=100 END=200Output Numbers that are divisible ... Read More

Count numbers in range 1 to N which are divisible by X but not by Y in C++

Sunidhi Bansal
Updated on 31-Oct-2020 04:47:44

639 Views

We are provided a number N. The goal is to find the numbers that are divisible by X and not by Y and are in the range [1, N].Let’s understand with examples.Input N=20 X=5 Y=20Output Numbers from 1 to N divisible by X not Y: 2Explanation Only 5 and 15 are divisible by 5 and not 10.Input N=20 X=4 Y=7Output Numbers from 1 to N divisible by X not Y: 5Explanation Numbers 4, 8, 12, 16 and 20 are divisible by 4 and not 7.Approach used in the below program is as followsWe take an integer N.Function divisibleXY(int x, int y, int n) returns a count ... Read More

Count numbers in a range that are divisible by all array elements in C++

Sunidhi Bansal
Updated on 31-Oct-2020 04:45:19

641 Views

We are provided two numbers START and END to define a range of numbers. And also an array of positive numbers Arr[]. The goal is to find all the numbers that are divisible by all elements of Arr[] and are in the range [START, END] .Method 1 ( Naive Approach )We will do this by traversing numbers from START to END and for each number we will check if the number is divisible by all elements of the array. If yes increment count.Method 2 ( check divisibility by LCM of array elements )We will find the LCM of all array ... Read More

Count numbers having 0 as a digit in C++

Sunidhi Bansal
Updated on 31-Oct-2020 04:41:17

2K+ Views

We are provided a number N. The goal is to find the numbers that have 0 as digit and are in the range [1, N].We will do this by traversing numbers from 10 to N ( no need to check from 1 to 9 ) and for each number we will check each digit using a while loop. If any digit is found as zero increment count and move to next number otherwise reduce the number by 10 to check digits until number is >0.Let’s understand with examples.Input N=11Output Numbers from 1 to N with 0 as digit: 1Explanation Starting from i=10 to ... Read More

Count numbers from range whose prime factors are only 2 and 3 in C++

Sunidhi Bansal
Updated on 31-Oct-2020 04:39:15

762 Views

We are provided two numbers START and END to define a range of numbers. The goal is to find the numbers that have only 2 and 3 as their prime factors and are in the range [START, END].We will do this by traversing numbers from START to END and for each number we will check if the number is divisible by 2 and 3 only. If divisible, divide it and reduce it. If not, break the loop. In the end if the number is reduced to 1 then it has only 2 and 3 as its factors.Let’s understand with examples.Input START=20 ... Read More

Count number of triplets with product equal to given number in C++

Sunidhi Bansal
Updated on 31-Oct-2020 04:36:35

249 Views

We are given an array Arr[] of integers with length n and a number M. The array is only containing positive integers. The goal is to count the triplets of elements of Arr[] which have product equal to M.We will do this by using three for loops. Increment count if arr[x]*arr[y]*arr[z]=M and x!=y!=z. (0

How to Handle Large CSV files with Pandas?

Sasanka Chitrakavi
Updated on 23-Oct-2020 13:59:07

1K+ Views

In this post, we will go through the options handling large CSV files with Pandas.CSV files are common containers of data, If you have a large CSV file that you want to process with pandas effectively, you have a few options.Pandas is an in−memory toolYou need to be able to fit your data in memory to use pandas with it. If you can process portions of it at a time, you can read it into chunks and process each chunk. Alternatively, if you know that you should have enough memory to load the file, there are a few hints to ... Read More

Advertisements