In number theory, a Leyland number is a number of the form xy + yx, where x and y are integers greater than 1 and 1 <y <= x.
Given a positive integer N. The task is to print first N Leyland number in ascending order. The first few Leyland numbers are 8, 17, 32, 54, 57, 100, …
Input : N = 1 Output : 8 22 + 22 = 4 + 4 = 8. Input : N = 6 Output : 100
The idea to run two loop, one for x and other for y. The outer loop start with 2 to n and for each iteration of outer loop, run inner loop start from 2 t x. And store xy + yx in an array. After calculating all the value sort them and print first n numbers.
Below is the implementation of this approach:
8 17 32 54 57 100
- Count number of trailing zeros in Binary representation of a number using Bitset
- Find minimum number to be divided to make a number a perfect square
- Count number of triplets with product equal to given number with duplicates allowed
- Given number of matches played, find number of teams in tournament
- Number of times the largest perfect square number can be subtracted from N
- Print a number strictly less than a given number such that all its digits are distinct.
- Querying maximum number of divisors that a number in a given range has
- Program to calculate the number of odd days in given number of years
- Count the number of operations required to reduce the given number
- Find the largest good number in the divisors of given number N
- Find the maximum number of composite summands of a number
- Find the number of jumps to reach X in the number line from zero
- Check if a number is divisible by all prime divisors of another number
- Minimum number of given powers of 2 required to represent a number
- Build Lowest Number by Removing n digits from a given number
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.