Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package diveinto;
- public class Diveinto{
- public static void main(String[] args) {
- float[] xname = {25, 20, 15, 10, 5, 1, 0, -1, -5, -10, -15, -20, -25};
- float s = 1, n = 1;
- float a;
- for(int i=0; i<xname.length; i++){
- a = xname[i];
- n = 1;
- s = 1;
- while (s + a != s) {
- s += a;
- n += 1;
- a *= Math.abs(xname[i]) / n;
- }
- System.out.println("\n");
- System.out.println(xname[i]+"\n"+"Алгоритм");
- if (xname[i] >= 0) {
- System.out.println(s);
- } else {
- System.out.println(1/s);
- }
- System.out.println("Встроенная");
- System.out.println(Math.pow(Math.E, xname[i]));
- System.out.println("Погрешность");
- System.out.println(Math.abs((Math.pow(Math.E, xname[i])-s) / Math.pow(Math.E, xname[i])));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement