The problem of this contest was to solve the exponential integral numerically:
I implemented an example solution in java which takes your a number x as input and integrates between 1/x and x by dividing it into 10⁹ sections:
public class abcd {
public static double f(double x) { // Whatever function you want to integrate.
return Math.exp(x)/x;
}
public static void main(String[] args) {
double xMax = Double.parseDouble(args[0]);
double xMin = 1/xMax;
double Δx = (xMax-xMin)/1.0e9;
double total = 0;
for(double x = xMin; x < xMax; x += Δx) {
total += f(x)*Δx;
}
System.out.println(total);
}
}
This prints out when used for my own reputation(57):
1.0156434538674713E23
This is pretty close to the value supplied by wolframalpha(thanks to @kaeserotor for mentioning it.), but still only a small amount of digits.
In the next contest you will apply a slightly different method for integrating this same function. It will be a lot more accurate(f you plug in numbers of the right magnitude…).
So you might want to keep your code for comparison.
↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓
Name | Solution found | Comment
↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓
Congratulations @kaeserotor and
@crokkon, you won 1 SBI each!
↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓↑↓