The Eratosthenes Shuffle Challenge

Write a function or program that accepts a line of input, performs a very specific and oddly familiar shuffle on its characters, and outputs the result.

The required shuffling can be described using the following algorithm:


Label each character in the input with a 1 based index.
Write character number 1 as output.
Starting with character number 2, write every other character to the output in order, excluding character 2 itself.  In other words, write characters 4, 6, 8, 10, and so on as output.
Starting with the next character number n not yet written as output, write every nth character to the output, excluding character n itself, and excluding any other character (by numeric label) you may have already written to the output.
Repeat step 4 as long it continues to add new characters to the output.
Write the remaining characters to output, in order.


Example


Label the characters.


  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
  O  L  D     D  O  C     Y  A  K  '  S     B  E  A  U  T  Y     C  O  R  N  E  R


2. Write the first character to output:

  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
  O  L  D     D  O  C     Y  A  K  '  S     B  E  A  U  T  Y     C  O  R  N  E  R
O


3. Write every other character starting with 2, excluding 2.

  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
  O  L  D     D  O  C     Y  A  K  '  S     B  E  A  U  T  Y     C  O  R  N  E  R
O O A' EUYCRE

4. The next character not yet written is character number 3; write every 3rd character starting with 3, but excluding character 3 itself, and any character already written.

  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
  O  L  D     D  O  C     Y  A  K  '  S     B  E  A  U  T  Y     C  O  R  N  E  R
O O A' EUYCREYB R

5. Repeat step 4 using the next character, character 5.

4. The next character not yet written is character number 5; write every 5th character starting with 5, but excluding character 5 itself, and any character already written.  (This amounts to just character 25).

  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
  O  L  D     D  O  C     Y  A  K  '  S     B  E  A  U  T  Y     C  O  R  N  E  R
O O A' EUYCREYB RN

5. The next character is 7; but 14, 21 have already been written, so no more characters would be output if we repeat step 4.  Thus, we're done with 5.

6. Write the remaining characters out in order.

  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
  O  L  D     D  O  C     Y  A  K  '  S     B  E  A  U  T  Y     C  O  R  N  E  R
O O A' EUYCREYB RNLDDCKSATO

Rules

Input and output may be via standard input/standard output, strings, or arrays of characters.

If reading in as standard input you may at your convenience assume there's a trailing newline, or that the entire input contains the line.  Newline characters do not participate in the shuffle.

Likewise, at your convenience, your output may either have a trailing newline or not.

Standard loopholes are disallowed.

This is a code golf competition.  Smallest code in bytes wins.

Test Cases

123456789ABCDEF -&gt; 1468ACE9F2357BD

OLD DOC YAK'S BEAUTY CORNER -&gt; O O A' EUYCREYB RNLDDCKSATO

Blue boxes use a 2600hz tone to convince telephone switches that use in-band signalling that the caller is actually a telephone operator.
-&gt;
Bebxsuea20h oet ovnetlpoesice htuei-adsgaln httecle satal  eehn prtre 0ncce ha nng aiuapootnt ihyon atallu o s 6z oi ehwstsnbilt lr clee.
Mathematica, 61 bytes

#[[SortBy[Range@Length@#,FactorInteger[#][[1,1]]PrimeQ@#&amp;]]]&amp;


Unnamed function taking a list of characters as input and returning a list of characters.

FactorInteger[#][[1,1]] yields the smallest prime factor of # (and returns 1 if # equals 1). Therefore FactorInteger[#][[1,1]]PrimeQ@# yields a strange expression: [#'s smallest prime factor] False if # is not prime, and # True if # is prime (these are unevaluated products of a number and a boolean).

Range@Length@# yields a list of the numbers up to the length of the input. Then SortBy sorts those numbers by the funny function described above. Mathematica is really type-sensitive in many ways, but cheerfully mixes them in other ways: expressions of the form [number] False are alphabetically sorted before expressions of the form [number] True, while ties are broken by sorting the numbers numerically. That produces exactly the permutation we want here, and #[[...]] permutes the characters of the input accordingly.