Skip to content

Instantly share code, notes, and snippets.

View heyrutvik's full-sized avatar

Rutvik Patel heyrutvik

View GitHub Profile
@heyrutvik
heyrutvik / person_survived.c
Last active August 29, 2015 14:06
100 people standing in a circle in the order 1 to 100. No.1 has a sword. He kills the next person (i.e. no. 2 ) and gives sword to next to next (i.e no.3). All persons do the same until only 1 survives. Which number survives at the end?
#include <stdio.h>
int main()
{
int n;
printf("Enter a number (must be <= 100): ");
scanf("%d", &n);
if (n <= 1) {
printf("There must be at least two people, my friend!\n");