Can someone interpret this code for me? I dont understand whats going on. This code is supposed to take a number n that is inputted and show all the numbers below n that are frugal.

A little background, a frugal number is a number where the amount of the digits in the number exceed the amount of digits in its prime factorization (including exponents). So for example, 1024 is a frugal number because 1024 = 2^10, where 1024 has 4 digits and 2^10 has 3 digits.

A code was given to me that compiles and executes exactly what is needed but all the variables, etc have been replaced by random letters, and im trying to figure out what each variable is so that it makes sense to someone reading it. Ive only been able to figure out what FactorDigits, DigitsCount, and n are. The rest i dont know cause i dont really understand what is going on.

Here is the code:

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

int m(int m) {
int c=0;
m: if (!m) goto c;
m/=10;
c++;
goto m;
c: return c;
}

int c(int c) {
int n=2,b=0,DigitsCount=m(c),FactorDigits=0;
m: if (!(c%n)) { b++; c/=n; goto m;}
if (!b) { n++; goto m; }
if (b>1) FactorDigits+=m(b);
FactorDigits+=m(n);
if (c==1 || FactorDigits>=DigitsCount) goto c;
n++;
b=0;
goto m;
c: if (DigitsCount>FactorDigits) return 1;
return 0;
}

int main () {
int n,b=2;
printf("Enter a number: ");
scanf("%d",&n);
m: if (c(b)) printf("%d\n",b);
if (++b<n) goto m;
}

Can someone please help me understand this with as much detail as possible.
Thanks

This article has been dead for over six months. Start a new discussion instead.