Given three non-negative integers a, d and x. Here, a is the first element, d is the difference of an AP (Arithmetic Progression). We need to find if x is part of given AP or not.
Input : a = 1, d = 3, x = 7 Output : Yes 7 is part of given AP, 1 + 3 + 3 = 7 Input : a = 10, d = 0, x = 10 Output : Yes
Firstly, in case d = 0, we should output Yes if a = x else answer is No. For non-zero d, if x belongs to sequence x = a + n * d where n is non-negative integer, only if (n – a) / c is non-negative integer.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Split the number into N parts such that difference between the smallest and the largest part is minimum
- Find the first natural number whose factorial is divisible by x
- Find the real and imaginary part of a Complex number
- Generate Array whose difference of each element with its left yields the given Array
- Partition N into M parts such that difference between Max and Min part is smallest
- Divide a sorted array in K parts with sum of difference of max and min minimized in each part
- Number of ways to split a binary number such that every part is divisible by 2
- Number of pairs from the first N natural numbers whose sum is divisible by K
- Find the smallest number whose digits multiply to a given number n
- Find First element in AP which is multiple of given prime
- Array formed from difference of each element from the largest element in the given array
- First N terms whose sum of digits is a multiple of 10
- Find a triplet in an array whose sum is closest to a given number
- Find number of factors of N when location of its two factors whose product is N is given
- Maximize Bitwise AND of first element with complement of remaining elements for any permutation of given Array
- Find M-th number whose repeated sum of digits of a number is N
- Split array into minimum number of subarrays having GCD of its first and last element exceeding 1
- Super Ugly Number (Number whose prime factors are in given set)
- Minimum number of squares whose sum equals to given number N | set 2
- Minimum number of squares whose sum equals to a given number N | Set-3
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.