My solution


#1

would be

__uint64_t test = 0; for (int i=0; i<64; i++) { if (i%2==0) // if even, shift left test = test << 1; else { // if uneven, shift left and make the first digit 1 (OR 1) test = test << 1; test |= 1; } } printf("Resutltat %lld", test);

Always open for recommendations and more elegant solutions


#2

Mine is similar, just the if-check is vice versa:

[code] unsigned long long myNumber = 0;

for (int i = 0; i < 64; i++) {
    if (i % 2) {
        myNumber = myNumber << 1; // myNumber <<= 1; would be possible as well
        myNumber = myNumber | 1; // myNumber |= 1; would be possible as well
    }
    else
    {

        myNumber = myNumber << 1; // myNumber <<= 1; would be possible as well
    }
}

printf("myNumber: %lld\n", myNumber);[/code]

#3

this is what I had done


      uint64_t big =0;
    
    int iI = 0;
    int insidecount =0;
    
    for ( iI = 0; iI < 63; iI ++){
        big = big << 1;
        
        if (insidecount % 2 ==0){
        big = big + 0x01;
            
        }
        insidecount++;
        
    }
    
    
    printf("Variable in Hex is  %llx\n", big);
    printf("Variable in Decimal is %llu\n",big);