Find if the given number is present in the infinite sequence or not | C ++ implementation of the approach ; Function that returns true if the sequence will contain B ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool doesContainB ( int a , int b , int c ) { if ( a == b ) return true ; if ( ( b - a ) * c > 0 && ( b - a ) % c == 0 ) return true ; return false ; } int main ( ) { int a = 1 , b = 7 , c = 3 ; if ( doesContainB ( a , b , c ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }