Possible values of Q such that , for any value of R , their product is equal to X times their sum | C ++ program for the above approach ; Function to find all possible values of Q ; Vector initialization to store all numbers satisfying the given condition ; Iterate for all the values of X ; Check if condition satisfied then push the number ; Possible value of Q ; Print all the numbers ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; void values_of_Q ( int X ) { vector < int > val_Q ; for ( int i = 1 ; i <= X ; i ++ ) { if ( ( ( ( X + i ) * X ) ) % i == 0 ) { val_Q . push_back ( X + i ) ; } } cout << val_Q . size ( ) << endl ; for ( int i = 0 ; i < val_Q . size ( ) ; i ++ ) { cout << val_Q [ i ] << " ▁ " ; } } int main ( ) { int X = 3 ; values_of_Q ( X ) ; return 0 ; }