For Riddler Express Challenge from 538
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This value is between 1/2019 and 1/2020.
Output:
Smallest denominator: 4039.0
Numerator for smallest denominator: 2.0