Beatty sequence (or homogeneous Beatty sequence) is the sequence of integers found by taking the floor of the positive multiples of a positive irrational number.
The Nth term of the Beatty sequence:
Find the N terms of Beatty Sequence
Given an integer N, the task is to print the first N terms of the Beatty sequence.
Input: N = 5
Output: 1, 2, 4, 5, 7
Input: N = 10
Output: 1, 2, 4, 5, 7, 8, 9, 11, 12,
Approach: The idea is to iterate from 1 to N using loop to find the term of the sequence. The term of the Beatty sequence is given by:
Below is the implementation of the above approach:
1, 2, 4, 5, 7,
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Look-and-Say Sequence
- Sum of the sequence 2, 22, 222, .........
- Gould's Sequence
- Aronson's Sequence
- Gijswijt's Sequence
- Alcuin's Sequence
- Connell Sequence
- k-th number in the Odd-Even sequence
- Find F(n) when F(i) and F(j) of a sequence are given
- Golomb sequence
- Sylvester's sequence
- Recaman's sequence
- Farey Sequence
- Increasing sequence with given GCD
- Aliquot Sequence
- Padovan Sequence
- Juggler Sequence
- Sum of numbers from 1 to N which are in Lucas Sequence
- Smarandache-Wellin Sequence
- Ulam Number Sequence
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.