Answer to Question #258338 in C for Lucifer

Question #258338

Josephus Problem using Circular Doubly Linked List. (Your program should print the remaining people in each iteration). also show output.


1
Expert's answer
2021-10-29T00:54:18-0400
#include <stdio.h>


int josephus(int num, int x)
{
	if (num == 1)
		return 1;
	else
		return (josephus(num - 1, x) + x - 1) % num + 1;
}


int main()
{
	int num = 25;
	int x = 3;
	printf("The place chosen is: %d", josephus(num, x));
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS