New course! Every coder should learn Generative AI!
Try a free lesson0
Can someone help me solve this
This is a code to solve the Joseph flavius problem in c# using System; public class Program { public static void Main() { int entrada = 0, potencia = 2, resultado = 0; Console.WriteLine("Ingrese el total de personas"); entrada = Convert.ToInt32(Console.ReadLine()); for (int i = 1; i < entrada; i++) { potencia = potencia * 2; } for (int i = 0; i <= potencia; i++) { potencia -= 1; if (i >= entrada) { i = 0; } else if (potencia <= 0) { Console.WriteLine(
quot;La posicion que sobrevive es la: {i}"); } } Console.ReadLine(); } }2 Answers
+ 3
Hint:
The question is how you want / should solve this task, in mathematicaly or program algorithmicaly way?
There are a few mathe solutions, for them you can search in web if you cannot it solve yourself.
Or you try to solve it with arrays / lists where are ones and zeros to manage.
0
https://code.sololearn.com/cQsg6iSE1RJY/?ref=app try this bro