40 lines
861 B
C
40 lines
861 B
C
#include <stdio.h>
|
|
#include <math.h>
|
|
/* This program is made available under the terms of the GNU copyleft*/
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
char buffer1[20];
|
|
char buffer2[20];
|
|
double symbols;
|
|
double proportion;
|
|
double actual_symbol;
|
|
|
|
/*get the nums*/
|
|
printf("How many symbols are available in this system ?\n");
|
|
//gets(buffer1);
|
|
if (fgets(buffer1,20,stdin) == NULL) { exit(1);}
|
|
|
|
printf("Of these, which symbol's Benford proportion do you want? ?\n");
|
|
//gets(buffer2);
|
|
if (fgets(buffer2,20,stdin) == NULL) { exit(1);}
|
|
|
|
/*conv to values*/
|
|
symbols=atol(buffer1);
|
|
actual_symbol=atol(buffer2);
|
|
|
|
/* benford's proportion = log to the base n of (1 + 1/D) where D is*/
|
|
/* some symbol included in the symbol set */
|
|
|
|
proportion = log10(1+(1/actual_symbol)) / log10(symbols);
|
|
|
|
|
|
printf("Symbol %g occurs with proportion %g.\n\n", actual_symbol, proportion);
|
|
|
|
|
|
return 0;
|
|
}
|
|
|