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 triplets with product equal to given number with duplicates allowed
- 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
- Number of possible permutations when absolute difference between number of elements to the right and left are given
- Number of times the largest perfect square number can be subtracted from N
- Given number of matches played, find number of teams in tournament
- Check whether all the rotations of a given number is greater than or equal to the given number or not
- Super Ugly Number (Number whose prime factors are in given set)
- Find the number of ways to divide number into four parts such that a = c and b = d
- Count the number of operations required to reduce the given number
- Program to Convert Octal Number to Binary Number
- Find the total number of composite factor for a given number
- 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
- Minimum number of given powers of 2 required to represent a 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.