07.-SUMA DE N PRIMEROS NUMEROS NATURALES
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package problema07;
import java.io.*;
/**
*
* @author abel montalvan
*/
public class PROBLEMA07 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
// TODO code application logic here
int n,s;
BufferedReader in =new BufferedReader(new InputStreamReader(System.in));
System.out.println("Número: ");
n=Integer.parseInt(in.readLine());
s=(n*(n+1))/2;
System.out.println("");
System.out.println("Suma: " + s);
}
}
No hay comentarios:
Publicar un comentario