I'm writing C code that converts from an integer to its binary representation, reverses the binary and then converts back to an integer. It's working well, but I need it to work for input values up to 10^9. Right now, it seems to break for anything larger than 10^7. What I mean is I put in a number such as 10000000 and get out 17967657062982931584 as being the binary representation (despite being accurate for smaller integers). In addition, I am not sure where my int\_to\_binary is the only function experiencing this problem, or if the others need to be optimized for large inputs as well. Any ideas where I'm going wrong? Thank you.

```
#include <stdio.h>
#include <string.h>

unsigned long long int_to_binary(unsigned long long k) {
    if (k == 0) return 0;
    if (k == 1) return 1;
    return (k % 2) + 10 * int_to_binary(k/2);
}

unsigned long long reverse_int(unsigned long long l) {
        unsigned long long reversed; 
    reversed = 0;
        while (l > 0) {
                reversed = reversed * 10 + (l%10);
                l = l / 10;
        }
        return reversed;
}

unsigned long long binary_to_int(unsigned long long k) {
    char binaryString[80];
    snprintf(binaryString, 4, "%llu", k);
    unsigned long long decimal = 0;
    int length = strlen(binaryString);
    int i = 0;
    while(i < length) {
        decimal = (decimal << 1) + (binaryString[i] - 0x30);
        i++;
    }
    return decimal;
}

int main() {
    int number;
    printf("Enter a number: ");
    scanf("%d", &number);
    printf("You entered %d\n", number);
    unsigned long long b = int_to_binary(number);
    printf("In Binary, this is %llu\n", b);
    unsigned long long c = reverse_int(b);
    printf("When we reverse it, it looks like this: %llu\n", c);
    unsigned long long d = binary_to_int(c);
    printf("And when we convert that back to an int, it looks like this: %llu\n", d);
        return 0;
}

```