#C13296. Every Nth Character
Every Nth Character
Every Nth Character
Given a string ( s ) and an integer ( n ), produce a new string composed of every nth character from the input string. More formally, if we consider the string indexing starting at 1, the result string consists of characters at positions ( n, 2n, 3n, \dots ) up to the length of ( s ). If ( n ) is less than or equal to 0, or if ( n ) is greater than the length of ( s ), the output should be an empty string.
For example, if ( s = \texttt{abcdefghijk} ) and ( n = 3 ), then the output should be ( \texttt{cfi} ) because the 3rd, 6th, and 9th characters of ( s ) are selected.
inputFormat
The input consists of two lines. The first line contains the string ( s ). The second line contains an integer ( n ). You should read the input from standard input (stdin).
outputFormat
Output a single line containing the new string formed by taking every nth character from ( s ) as described. The output should be printed to standard output (stdout).## sample
abcdefghijk
3
cfi