Euler Zigzag numbers is a sequence of integers which is a number of arrangements of those numbers so that each entry is alternately greater or less than the preceding entry.
c1, c2, c3, c4 is Alternating permutation where
c1 < c2
c3 < c2
c3 < c4…
zigzag numbers are as follows 1, 1, 1, 2, 5, 16, 61, 272, 1385, 7936, 50521 ……
For a given integer N. The task is to print sequence up to N terms.
Input : N = 10
Output : 1 1 1 2 5 16 61 272 1385 7936
Input : N = 14
Output : 1 1 1 2 5 16 61 272 1385 7936 50521 353792 2702765 22368256
The (n+1)th Zigzag number is :
We will find the factorial upto n and store them in an array and also create a second array to store the i th zigzag number and apply the formula stated above to find all the n zigzag numbers.
Below is the implementation of the above approach :
zig zag numbers: 1 1 1 2 5 16 61 272 1385 7936
- Euler's Totient function for all numbers smaller than or equal to n
- Increasing permutation of first N natural numbers
- Find the good permutation of first N natural numbers
- Find a permutation of 2N numbers such that the result of given expression is exactly 2K
- Find the permutation of first N natural numbers such that sum of i % Pi is maximum possible
- Find permutation of first N natural numbers that satisfies the given condition
- Find the number of sub arrays in the permutation of first N natural numbers such that their median is M
- Minimum number of given operations required to convert a permutation into an identity permutation
- Euclid Euler Theorem
- Euler's Four Square Identity
- Euler's Totient Function
- Check if a number is Euler Pseudoprime
- Minimum number of replacements to make the binary string alternating | Set 2
- Euler Method for solving differential equation
- Count integers in a range which are divisible by their euler totient value
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.