Problem 57 (with incorrect version (due to limitatations of size of long double) in C).
This commit is contained in:
parent
27cae54601
commit
27ae417e11
|
@ -0,0 +1,18 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
int main () {
|
||||
long double numerator = 3;
|
||||
long double denominator = 2;
|
||||
int count = 0;
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
long double newDen = numerator + denominator;
|
||||
long double newNum = newDen + denominator;
|
||||
numerator = newNum;
|
||||
denominator = newDen;
|
||||
if ((int) floor (log10 (numerator)) > (int) floor (log10 (denominator)))
|
||||
count++;
|
||||
}
|
||||
printf ("count: %d\n", count);
|
||||
}
|
Loading…
Reference in New Issue