You are on page 1of 1

// -*- coding:utf-8 -*-

// author : Grimorio
// description : solutions for codewars.com
// updated at : 2023-03-1 23:3
// -----------------------------------------------------
// Kata UUID : 566fc12495810954b1000030
// Title : Count the Digit
// Kyu : 7 kyu
// Tags : ['Fundamentals']
// Language : C
// ----------------------------------------------------

#include <stdio.h>

int nbDig(int n, int d) {


int square;
int count = 0;

for (int i = 1; i <= n; i++)


{
square = i*i;

while (square)
{
if(square % 10 == d) count++;
square /= 10;
}
}

return count;
}

int main(void) {

int x, y;

while(scanf("%d%d", &x, &y) != EOF) {


printf("%d\n", nbDig(x, y));
}

return 0;
}

You might also like