Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- sqrt(a)+sqrt(b)=sqrt(2020)_v1.c
- Task:
- sqrt(a)+sqrt(b)=sqrt(2020)
- Find a and b.
- You can find all my C programs at Dragan Milicev's pastebin:
- https://pastebin.com/u/dmilicev
- */
- #include <stdio.h>
- #include <math.h>
- #define NUM_OF_ITERATIONS 1000
- int main(void)
- {
- int a, b, number_of_solutions=0;
- double c = sqrt(2020);
- for(a=1; a<NUM_OF_ITERATIONS; a++)
- for(b=1; b<NUM_OF_ITERATIONS; b++)
- {
- if( abs(c - sqrt(a) - sqrt(b)) < 0.1 )
- {
- number_of_solutions++;
- printf("\n a = %d \t b = %d \n", a, b );
- printf(" \n %.16lf = sqrt(a) \n %.16lf = sqrt(b) \n %.16lf = c-sqrt(a)-sqrt(b) \n", sqrt(a), sqrt(b), c - sqrt(a) - sqrt(b) );
- }
- }
- if( number_of_solutions == 0 )
- printf("\n There is no such digits. \n");
- else
- printf("\n There are %d solutions. \n", number_of_solutions );
- return 0;
- } // main()
Add Comment
Please, Sign In to add comment