One of the numbers 1 to 9 is selected and the following operation is performed.
Multiply a given number by 3 first, and if the result is 10 or more, leave only the number of digits in the work and multiply it by 3 again.
Write a program that outputs the number of times multiplied by 3 until the operation is first selecte
TT... plz
#include <stdio.h>
int main(void)
{
int a = 1;
int count, b;
scanf("%d", &a);
if (a>0, a<10)
{
while(b=a)
{
b = a * 3;
if(b > 10)
{
b = b % 10;
count++;
}
}
printf("%d",count);
}
else if (a<1,a>9)
{
printf("1에서 9사이의 수 중에서 입력해주세요.");
}
return 0;
}