Number In Arithmetic Progression Problem

Given three integers X, C, and Y, where X is the first term of an arithmetic sequence with a common difference of C, determine if Y is part of this arithmetic sequence.

Example:

Input:
X = 6, C = 3
Output:
Sequence: 6, 9, 12, 15, 18, 21, 24...

Explanation:

Based on the above sequence, you need to check if the given Y lies within this set of numbers.

Constraints:

  • 1 <= T <= 105
  • -108 <= X, C, Y <= 108

Time Limit: 1 sec

Input:

T - number of test cases
X, Y, C - space-separated integers for each test case

Output:

For each test case, print "True" if Y belongs to the sequence; otherwise, print "False".

Note:

You are not required to print anything. Simply implement the function to return the answers.
AnswerBot
4d

Determine if a given number is part of an arithmetic sequence with a specified first term and common difference.

  • Calculate the arithmetic sequence based on the given first term and common difference.

  • Ch...read more

Help your peers!
Add answer anonymously...
Paytm Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter