Beatty sequence | Function to print the first N terms of the Beatty sequence ; Driver code
function BeattySequence ( n ) { for ( let i = 1 ; i <= n ; i ++ ) { let ans = parseInt ( Math . floor ( i * Math . sqrt ( 2 ) ) ) ; document . write ( ans + " " ) ; } } let n = 5 ; BeattySequence ( n ) ;