
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int logstar(double x) {
  if (x <= 0)
    return -1;
  else if (x <= 1) 
    return 0;
  else
    return (1+logstar(log10(x)));
}

int logstar2(double x) {
  int d = 0;
  if (x <= 0) 
    return -1;
  else {
    while (x > 1) {
      x = log10(x);
      d++;
    }
    return d;
  }
}

int main (void) {
  double y;
  printf("Enter your number: ");
  scanf("%lf", &y);
  printf("Logstar value is %d.\n", logstar(y));   /* Or can use logstar2 */
  return EXIT_SUCCESS;
}
