param { number } sum return { number [ ] } function FindContinousSequence ( sum ) { if ( sum < 1 ) { return [ ] ; } let result = [ ] ; let child = [ 1 , 2 ] ; let left = 1 ; let right = 2 ; let currentSum = 3 ; while ( right < sum ) { while ( currentSum < sum && right < sum ) { child . push ( ++ right ) ; currentSum += right ; } while ( currentSum > sum && left < sum ) { child . shift ( ) ; currentSum -= left ++ ; } if ( currentSum === sum && child . length > 1 ) { result . push ( child . slice ( ) ) ; child . push ( ++ right ) ; currentSum += right ; } } return result ; } export { FindContinousSequence } ;