Language : C(NOTE : Try a few times yourself before moving to the solution)
#include <stdio.h>
int sum_of_digits(int n){
int sum=0,rem=0;
if(n<10)
return n;
while (n>=10){
rem = n % 10;
sum+=rem;
rem = n/10;
if (rem < 10)
sum += rem ;
n = rem ;
}
return sum;
}
int main() {
int Times,n,sum;
scanf("%d",&Times);
while(Times--){
scanf("%d",&n);
do
{
sum = sum_of_digits(n);
n++;
} while (sum % 4);
printf("%d\n",n-1);
}
return 0;
}
No comments:
Post a Comment