Question

I want to know if for any base the most significant digit is 1 or not. Here is the code:

for(int i=3;i<=a;i++)
  {
    int x = i;
    int r = a;
    while(r/x)
    {
      r = r/x;
    }
    int rem = r%x;
    if(r==1)
    {
      count++;
    }
  }

is there any optimal way to replace the while loop nested in the for loop.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with cs.stackexchange
scroll top