Given two integers N and K, find Z, the number of non-negative integers that are less than or equal to N and whose sum of digits is divisible by K.
Answers
Answered by
0
Answer:
import java.util.*;
class chill
{
public static void main ()
{
Scanner sc=new Scanner(System.in);
int n,k,z=0,i,p,s;
System.out.println("Enter two Integers");
n=sc.nextInt();
k=sc.nextInt();
for(i=0;i<=n;i++)
{
p=i;
s=0;
while(p>0)
{
s=s+(p%10);
p/=10;
}
if (k%s==0)
z++;
}
System.out.println("Required result="+z);
}
}
Similar questions
Computer Science,
4 months ago
Hindi,
4 months ago
Computer Science,
4 months ago
History,
9 months ago
Science,
9 months ago
Math,
11 months ago