First collision point of two series | Javascript program to calculate the colliding point of two series ; Iterating through n terms of the first series ; x is i - th term of first series ; d is first element of second series and c is common difference for second series . ; If no term of first series is found ; Driver Code
function point ( a , b , c , d , n ) { let x ; let flag = 0 ; for ( let i = 0 ; i < n ; i ++ ) { x = b + i * a ; if ( ( x - d ) % c == 0 && x - d >= 0 ) { document . write ( x ) ; flag = 1 ; break ; } } if ( flag == 0 ) { document . write ( " " ) ; } } let a = 20 ; let b = 2 ; let c = 9 ; let d = 19 ; let n = 20 ; point ( a , b , c , d , n ) ;