Skip to content

Instantly share code, notes, and snippets.

@sanohin
Created October 25, 2015 13:20
Show Gist options
  • Select an option

  • Save sanohin/71c86a2e00bc4dd09112 to your computer and use it in GitHub Desktop.

Select an option

Save sanohin/71c86a2e00bc4dd09112 to your computer and use it in GitHub Desktop.
package lab;
import acm.program.*;
public class sedmoe extends ConsoleProgram {
public void run (){
double ep = readDouble("ep: ");
double x = readDouble("x: ");
println (fun (x, ep));
}
private double fun(double i, double j){
int n=0;
double sum=1;
double frst=1;
while (Math.abs(frst)>j){
n++;
frst= frst * (i/n);
sum = sum + frst;
}
return sum;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment