Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Punto7 { // basado en la formulas de sucesión aritmetica.
- public static void main(String[] arg){
- Scanner input = new Scanner(System.in);
- System.out.println("ingrese cantidad de los primeros numeros impares que desee sumar");
- int pf =input.nextInt(); // Ingresa pf(posición final)
- int vf=(2*pf)-1; // busca valor de pf()
- int sumatotal=((1+vf)/2)*pf; // sumatoria de valor inicial (1) y final (vf),dividido por la distancia en común
- System.out.println(sumatotal); // y finalmente multiplicado por la posicion final. Se muestra la suma total.
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement