Function to find the gcd of a path
function find_gcd ( arr ) { if ( arr . length == 1 ) return arr [ 0 ] ; let g = arr [ 0 ] ; for ( let i = 1 ; i < arr . length ; i ++ ) { g = gcd ( g , arr [ 1 ] ) ; } return g ; }