Hello and sorry if this question has been asked before, but I'm working on the Josephus problem and this is the code that I´ve written.
#include<stdio.h>
#include<cs50.h>
#include<math.h>
int main(void)
{
printf("Number of people: ");
float f=GetFloat();
const int a=pow(2,floor(log(f)/log(2)));
float c= 2*(f-2^a)+1;
printf("%f\n", c);
}
When I try to compile it it gives me this error message.
clang -ggdb3 -O0 -std=c99 -Wall -Werror Josephus.c -lcs50 -lm -o Josephus
Josephus.c:11:20: error: invalid operands to binary
expression ('float' and 'float')
float c= 2*(f-2^a)+1;
~~~^~
The equation I'm trying to write in the code is c = 2(f – 2^a) + 1 Where "c" is the number I'm looking for, "f" is the number of people and "a" is the largets power of 2 smaller than f.
Sorry for any and all grammatical mistakes and my lack of knowledge of the topic, I'm new to programming. Cheers!