Necessito desse codigo em visual g
FilipeTeixeira (0)

Historian Flavius ​​Josephus reports how, in the Roman-Jewish conflict in 67 AD, the Romans took the town of Jotapata, where he was commander. After escaping from Jotapata, Josephus found himself trapped in a cave with 40 other companions. The Romans discovered the hiding place and made an invitation for him to surrender, but his companions refused to allow him to do so. He then suggested that they do a kind of collective suicide, where one by one, everyone would be killed, in an order to be defined by the group and one would be killed by the other. All were in a circle and turned towards the center. Starting at a certain point, clockwise, every third person would be dead. The only survivor was Josephus, who surrendered to the Romans. This brings us to the question: did Josephus already know exactly where to stay so that he was the only survivor?

To prepare for a situation like this, write a program that determines which position you must stay in the circle in order to survive. You should inform the number of people in the circle (n> 0), the position of the person who will start the suicide (1 <= i <= n) and the "step", that is, how many people, be killed (k> 0).

· N> 0 people are organized in a circle, facing the center and numbered from 1 to n clockwise;

· Starting at person i, counts clockwise, until it reaches the person of value k (k> 0), who is killed immediately;

· We continue to count k people clockwise, from the person to the left of the one who was killed;

This process is repeated indefinitely, until only one person is the survivor.
'' '

people = 0
home = 0
step = 0

while (people <= 0):
people = int (float (input ('1. Number of people in circle:')))

while (start <= 0):
start = int (float (input ('2. Position of person who will start suicide:')))

while (step <= 0):
step = int (float (input ('3. Enter the' step ':')))

print ('--------------')
print ('- Selection: -')
print ('people:' + str (people))
print ('start:' + str (home))
print ('step:' + str (step))
print ('--------------')

list = list (range (1, people + 1))

step - = 1
idx = step
while len (list)> 1:
print (list)
list.remove (list [idx])
idx = (idx + step)% len (list)

The position you should be in the circle to be able to survive is' + str (list [0]) + 'counting from left to right.'

You are viewing a single comment. View All
EduFaus (8)

en esta pagina ay que escrubir en ingles y no es un sitio para poner preguntas es para crear tutoriales