Generation

generate functionTue, 23 May 2023

Hallar 𝑆=12+13+14+⋯…+1𝑁+1 Donde N, es ingresado por el teclado.

public class serie { public static void main(String[] args) { int a=1; int b=1; int c; int d=0; int e=0; int n=Integer.parseInt(JOptionPane.showInputDialog("Ingrese un numero: ")); for(int i=0;i<=n;i++){ c=a+b; e=c+e; d=d+e; a=b; b=c; } JOptionPane.showMessageDialog(null,"La suma de la serie es : "+d); } }

Questions about programming?Chat with your personal AI assistant