Language: C

 int m,n,k,i,a,s=1,g=1;
 long double d,o;
    scanf("%d%d",&n,&k);
    
    m = n;
    while(m>n){
        m=m*2;
        s++;
    }
    
    for(int r=1;r<=s-1;r++){
        g=g*2;
    }
    
    a=n-g+1;
    i=g/2;
    
    o=s-1+a-1/g-a/i;
    
    d=o/n;
    
    printf("%d",d);
    
    
    
   return 0;
}


Compiler output:
main.c:3:11: error: expected declaration specifiers or '...' before string constant
    3 |     scanf("%d%d",&n,&k);
      |           ^~~~~~
main.c:3:18: error: expected declaration specifiers or '...' before '&' token
    3 |     scanf("%d%d",&n,&k);
      |                  ^
main.c:3:21: error: expected declaration specifiers or '...' before '&' token
    3 |     scanf("%d%d",&n,&k);
      |                     ^
main.c:5:5: warning: data definition has no type or storage class
    5 |     m = n;
      |     ^
main.c:5:5: error: type defaults to 'int' in declaration of 'm' [-Wimplicit-int]
main.c:5:9: error: initializer element is not constant
    5 |     m = n;
      |         ^
main.c:6:5: error: expected identifier or '(' before 'while'
    6 |     while(m>n){
      |     ^~~~~
main.c:11:5: error: expected identifier or '(' before 'for'
   11 |     for(int r=1;r<=s-1;r++){
      |     ^~~
main.c:11:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<=' token
   11 |     for(int r=1;r<=s-1;r++){
      |                  ^~
main.c:11:25: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token
   11 |     for(int r=1;r<=s-1;r++){
      |                         ^~
main.c:15:5: warning: data definition has no type or storage class
   15 |     a=n-g+1;
      |     ^
main.c:15:5: error: type defaults to 'int' in declaration of 'a' [-Wimplicit-int]
main.c:15:7: error: initializer element is not constant
   15 |     a=n-g+1;
      |       ^
main.c:16:5: warning: data definition has no type or storage class
   16 |     i=g/2;
      |     ^
main.c:16:5: error: type defaults to 'int' in declaration of 'i' [-Wimplicit-int]
main.c:16:7: error: initializer element is not constant
   16 |     i=g/2;
      |       ^
main.c:18:5: warning: data definition has no type or storage class
   18 |     o=s-1+a-1/g-a/i;
      |     ^
main.c:18:5: error: type defaults to 'int' in declaration of 'o' [-Wimplicit-int]
main.c:18:5: error: conflicting types for 'o'; have 'int'
main.c:2:16: note: previous declaration of 'o' with type 'long double'
    2 |  long double d,o;
      |                ^
main.c:20:5: warning: data definition has no type or storage class
   20 |     d=o/n;
      |     ^
main.c:20:5: error: type defaults to 'int' in declaration of 'd' [-Wimplicit-int]
main.c:20:5: error: conflicting types for 'd'; have 'int'
main.c:2:14: note: previous declaration of 'd' with type 'long double'
    2 |  long double d,o;
      |              ^
main.c:22:12: error: expected declaration specifiers or '...' before string constant
   22 |     printf("%d",d);
      |            ^~~~
main.c:22:17: error: expected declaration specifiers or '...' before 'd'
   22 |     printf("%d",d);
      |                 ^
main.c:26:4: error: expected identifier or '(' before 'return'
   26 |    return 0;
      |    ^~~~~~
main.c:27:1: error: expected identifier or '(' before '}' token
   27 | }
      | ^