A children's game of 'count out' is played as followed. '40' children are arranged in a circle, a sentence containing of 'm' words is used to eliminate '1' child at a time until '1' child is left. Starting at child '1' the children are counted from '1' to 'm' and the 'm' th child is eliminates. Starting with the child after the one just eliminated the children are then counted from '1' to 'm' and the 'm'th child is eliminated. This is repeated until one child is left. Counting is done circularly and eliminated children are not counted. Write a program to read a value for m and print the number of the last remaining child.

Recommended Answers

All 2 Replies

Pascal is a defunct language. Even the inventor of it redid it as Modula! If your school is still teaching Pascal, go somewhere else!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.