#include <math.h> #include <stdio.h> void main() //can be replaced with int main, i prefer void main { int i =1,j; printf("Enter the Number: "); scanf("%d",&j); double k = 0,l = log(10); for(;i<=j;i++) { k = k + (log(i)/l); } k = (int) (k+0.5); printf("\n NOD: %f",k+1); } Source: http://inder-gnu.blogspot.com/2009/09/find-number-of-digits-in-number.html