Find the coordinates of a triangle whose Area = ( S / 2 ) | Javascript implementation of the approach ; Function to find the triangle with area = ( S / 2 ) ; Fix the two pairs of coordinates ; Find ( X3 , Y3 ) with integer coordinates ; Driver code
let MAX = 1000000000 ; function findTriangle ( S ) { let X1 = 0 , Y1 = 0 ; let X2 = MAX , Y2 = 1 ; let X3 = ( MAX - S % MAX ) % MAX ; let Y3 = ( S + X3 ) / MAX ; document . write ( " " + X1 + " " + Y1 + " " ) ; document . write ( " " + X2 + " " + Y2 + " " ) ; document . write ( " " + X3 + " " + Y3 + " " ) } let S = 4 ; findTriangle ( S ) ;