Beatty sequence | C ++ implementation of the above approach ; Function to print the first N terms of the Beatty sequence ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; void BeattySequence ( int n ) { for ( int i = 1 ; i <= n ; i ++ ) { double ans = floor ( i * sqrt ( 2 ) ) ; cout << ans << " , ▁ " ; } } int main ( ) { int n = 5 ; BeattySequence ( n ) ; return 0 ; }