Question

Write a C program to find out the number of ordered pairs (a,b) of positive integers,...

Write a C program to find out the number of ordered pairs (a,b) of positive integers, such that: 1/a + 1/b = 3/2018.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

#include "bits/stdc++.h"
using namespace std;
// used long long int to counter overflow
// function to return value of the experession 2018*b/(3*b-2018)
long double value(long long int b){
return (long double)(2018*b)/(3*b-2018);
}

signed main(){
long long int bl = 673 , br = 1358114;
long long int ans = 0;
// loop over every possible value of b
for(long long int b = bl;b<=br;b++)
// if the value of a is a interger ans++
if((long long int)value(b) == value(b)) ans++;
cout<<ans<<endl;
}

Add a comment
Know the answer?
Add Answer to:
Write a C program to find out the number of ordered pairs (a,b) of positive integers,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT