Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int main()
- {
- int number, lower_limit, upper_limit, divisor;
- long double division_result, subtraction_result, absolute_value, lowest_value;
- lowest_value=1;
- for(number=100; number<=10000; number++)
- {
- lower_limit=(int)(number/3.2);
- upper_limit=(int)(number/3.1);
- for(divisor=lower_limit; divisor<=upper_limit; divisor++)
- {
- division_result=(long double)(number)/(long double)(divisor);
- subtraction_result=division_result-M_PI;
- absolute_value=fabsf(subtraction_result);
- if(absolute_value<lowest_value)
- {
- lowest_value=absolute_value;
- printf("%i / %i = %.9LF\n", number, divisor, division_result);
- }
- }
- }
- return(0);
- }
- /*
- 100 / 31 = 3.225806452
- 100 / 32 = 3.125000000
- 101 / 32 = 3.156250000
- 104 / 33 = 3.151515152
- 107 / 34 = 3.147058824
- 110 / 35 = 3.142857143
- 179 / 57 = 3.140350877
- 201 / 64 = 3.140625000
- 223 / 71 = 3.140845070
- 245 / 78 = 3.141025641
- 267 / 85 = 3.141176471
- 289 / 92 = 3.141304348
- 311 / 99 = 3.141414141
- 333 / 106 = 3.141509434
- 355 / 113 = 3.141592920
- */
Add Comment
Please, Sign In to add comment