I attempted to convert a base 10 number to a base 6 number in C, but my code failed two hidden test cases.
I don't see any logical flaws in it.
Could you do it?
//convert base 10 to base 6
#include<stdio.h>
int main()
{
int num, rem = 0, i = 1, res = 0;
scanf("%d", &num);
while(num!=0)
{
rem = num%6;
res = (rem*i)+res;
num = num/6;
i = i*10;
}
printf("%d",res);
}