Computer Science, asked by salahuddinmahmood, 9 months ago

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 tamaghnadey1916
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