Possible values of Q such that , for any value of R , their product is equal to X times their sum | Java 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
import java . util . * ; class GFG { static void values_of_Q ( int X ) { ArrayList < Integer > val_Q = new ArrayList < Integer > ( ) ; for ( int i = 1 ; i <= X ; i ++ ) { if ( ( ( ( X + i ) * X ) ) % i == 0 ) { val_Q . add ( X + i ) ; } } System . out . println ( val_Q . size ( ) ) ; for ( int i = 0 ; i < val_Q . size ( ) ; i ++ ) { System . out . print ( val_Q . get ( i ) + " ▁ " ) ; } } public static void main ( String [ ] args ) { int X = 3 ; values_of_Q ( X ) ; } }