:starwars: Saludos mis estimados, miren necesito su ayuda para resolver un problema de programacion, bien comencemos esta es la problematica:
Your task is to find the sum of all integer numbers lying between 1 and N inclusive.
Input Specification
The input consists of a single integer N that is not greater than 10000 by it's absolute value.
Output Specification
Write to the output a single integer number that is the sum of all integer numbers lying between 1 and N inclusive.
Ejemplo
INPUT:
3
OUTPUT:
6
recurro a ustedes por que sinceramente ya no busco que modificarle a mi codigo, para mi ya esta correcto pero el sistema de evaluacion me lo detecta como incorrecto, la solucion debe ser dinamica, por salida y entrada estandar, este es el codigo que tengo, y que para mi funciona pero algo me debe estar faltando, ayuda plis
import java.io.*;
import java.util.*;
public class Main{
public static void main(String a[])throws Exception{
Scanner in=new Scanner(System.in);
int n,c=1,suma=0;
while(in.hasNextInt()){
n=Math.abs(in.nextInt());
if(n<=10000){
while(c<=n){
suma+=c;
c++;
}
System.out.println(suma);
}
}
}
}
Your task is to find the sum of all integer numbers lying between 1 and N inclusive.
Input Specification
The input consists of a single integer N that is not greater than 10000 by it's absolute value.
Output Specification
Write to the output a single integer number that is the sum of all integer numbers lying between 1 and N inclusive.
Ejemplo
INPUT:
3
OUTPUT:
6
recurro a ustedes por que sinceramente ya no busco que modificarle a mi codigo, para mi ya esta correcto pero el sistema de evaluacion me lo detecta como incorrecto, la solucion debe ser dinamica, por salida y entrada estandar, este es el codigo que tengo, y que para mi funciona pero algo me debe estar faltando, ayuda plis
import java.io.*;
import java.util.*;
public class Main{
public static void main(String a[])throws Exception{
Scanner in=new Scanner(System.in);
int n,c=1,suma=0;
while(in.hasNextInt()){
n=Math.abs(in.nextInt());
if(n<=10000){
while(c<=n){
suma+=c;
c++;
}
System.out.println(suma);
}
}
}
}