joseph ring

WBOY
Release: 2016-07-25 08:47:31
Original
890 people have browsed it
The Joseph Ring is a mathematical application problem: it is known that n people (represented by numbers 1, 2, 3...n respectively) are sitting around a round table. Start counting from the person numbered k, and the person who counts to m comes out of the queue; the next person starts counting from 1, and the person who counts to m comes out of the queue again; repeat this pattern until around the round table All the people came out.
                 
                                                                                                                                                                                                                                                                                                                     


function king($n, $m)
    {
  1. $monkey = range(1, $n);//Simulate a continuous array
  2. $i = 0;
  3. while (count($monkey) > ;= 1)
  4.                                                                                                                                                                                                                                                                                                 ; )
  5.                                         array_push($monkey,                                                                                                                                                       [] = $head;
  6. }
  7. }
  8. Return $out;
  9. }
  10. $out = king(9, 5);
  11. print_r($out);
  12. Copy code
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template