//
// main.c
// 단기 연구 과제
// Created by Shiro Nai on 07/05/2019.
// Copyright © 2019 Shiro Nai. All rights
// reserved.
#include <stdio.h>
#include <math.h>
int main(int argc, const char * argv[]) {
double n;
printf("How many people?");
scanf("%lf", &n);
int k = floor(log10(n)/log10(2));
printf("The last standing person's number is %lf.", (2*(n-(2^k)))+1);
return 0;
}
The output is different from what I expected.
For example, when n
=5 the answer is 3, but I get 11 for the output.