Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 398 Weeks Ago, 4 Days Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Computer Science Posted 17 Sep 2017 My Price 8.00

KING OF THE RING

Children of New Bernsburg love to play creative games. Once upon a time they decided to play a game called, "KING OF THE RING".

In this game they form a ring, a random child is selected and they start counting clockwise from that child until a fixed number (n, which is given at the starting of the game) is reached. When the count reaches n, the child on the nth spot is eliminated. The game continues again starting with the next child and the process continues until a single child remains.

Your aim is to print the position of the child which remains till last and hold the title King of the Ring.

Input

The first line of input contains number of children, m and the second line contains the fixed number, n, the factor by which children are eliminated.

Output

The output must print the position of the last child staying in the game.

Example

Input: 10 6 Output: 3q2

There are n bulbs in a row lighted during a marriage ceremony. A mischievous boy was passing from nearby when he had a naughty idea of breaking the bulbs. To make it interesting he does so in a pattern. He decides to smash every second lighted bulb on his first traversal, every third lighted bulb on his second traversal and so on. Getting exhausted at end he found that some of the bulbs remain lucky, not to be broken even during his indefinite process.

Your aim is to design a program which takes the input n i.e. number of bulbs and finds the position number of the still lighted bulbs.

Input

First line contains number of test cases t such that 0

The next t lines contain a single integer (n) each, such that 0

Output

The output should consist of t lines. Each line containing a single space separated positions of the lighted bulbs after the process.

Example

Input: 3 10 20 50 Output: 1 3 7 1 3 7 13 19 1 3 7 13 19 27 39 49

Answers

(5)
Status NEW Posted 17 Sep 2017 05:09 AM My Price 8.00

Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll

Not Rated(0)