Question
Multiverse Arena
Example 1:
Input:
5
Output:
1 2 3 4 5
Explanation:
Since n = 5 is odd, the sequence counts from 1 to 5.
Example 2:
Input:
4
Output:
4 3 2 1
Explanation:
Since n = 4 is even, the sequence counts down from 4 to 1.
In the mystical Multiverse Arena, warriors wield two types of magical weapons: Loopers and Breakers.
Depending on the magic number they receive, the warriors must cast their spells in a specific sequence:
1. If the number is even, the warrior casts a descending spell, counting from the number down to 1.
2. If the number is odd, the warrior casts an ascending spell, counting from 1 up to the number.
Your task is to help the mage generate the correct sequence of spell strikes.
Depending on the magic number they receive, the warriors must cast their spells in a specific sequence:
1. If the number is even, the warrior casts a descending spell, counting from the number down to 1.
2. If the number is odd, the warrior casts an ascending spell, counting from 1 up to the number.
Your task is to help the mage generate the correct sequence of spell strikes.
Input
A single integer n, representing the magical number.
Output
Print the generated sequence of numbers in a single line, space-separated, representing the order of the warrior's strike.
Example
Example 1:
Input:
5
Output:
1 2 3 4 5
Explanation:
Since n = 5 is odd, the sequence counts from 1 to 5.
Example 2:
Input:
4
Output:
4 3 2 1
Explanation:
Since n = 4 is even, the sequence counts down from 4 to 1.