package Lecture3; import javax.swing.*; public class Iteration { public static void main(String[] args) { String entrada= JOptionPane.showInputDialog("Introduzca x (0-2)"); double x= Double.parseDouble(entrada); // Calcule 20 términos del // ln x= (x-1) - (x-1)^2/2 + (x-1)^3/3 - ... final int ITERACIONES= 20; double logx= 0.0; double x1= x-1; for (int i= 1; i <= ITERACIONES; i++) { if (i % 2 == 0) // i par logx -= Math.pow(x1, i)/i; else logx += Math.pow(x1, i)/i; } System.out.println("Ln x= " + logx); System.exit(0); } }