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
- 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
- Count number of trailing zeros in Binary representation of a number using Bitset
- Number of possible permutations when absolute difference between number of elements to the right and left are given
- Given number of matches played, find number of teams in tournament
- Number of times the largest perfect square number can be subtracted from N
- Number of ways to split a binary number such that every part is divisible by 2
- Find the number of positive integers less than or equal to N that have an odd number of digits
- Build Lowest Number by Removing n digits from a given number
- Represent a number as a sum of maximum possible number of Prime Numbers
- Number of times a number can be replaced by the sum of its digits until it only contains one digit
- Querying maximum number of divisors that a number in a given range has
- Count number of ways to divide a number in 4 parts
- Super Ugly Number (Number whose prime factors are in given set)
- Program to calculate the number of odd days in given number of years
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.