Skip to content

Instantly share code, notes, and snippets.

@nolgan nolgan/SmallestDenominator.java Secret
Last active Jan 12, 2020

Embed
What would you like to do?
For Riddler Express Challenge from 538
public class SmallestDenominator {
public static void main(String[] args) {
double min_denominator = 1000000000;
double numerator = 0;
for(double i=1;i<100000;i++){
for(double j=1;j<50000;j++){
if(((double)1/2019 > i/j) && (i/j > (double)1/2020)){
if(j<min_denominator){
min_denominator = j;
numerator = i;
}
}
}
}
System.out.println("Smallest denominator: " + min_denominator);
System.out.println("Numerator for smallest denominator: " + numerator);
}
}
@nolgan

This comment has been minimized.

Copy link
Owner Author

nolgan commented Jan 12, 2020

This value is between 1/2019 and 1/2020.

Output:

Smallest denominator: 4039.0
Numerator for smallest denominator: 2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.