Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created October 25, 2022 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/5b1cbfea188f72a2ac8702138a1f438e to your computer and use it in GitHub Desktop.
Save parzibyte/5b1cbfea188f72a2ac8702138a1f438e to your computer and use it in GitHub Desktop.
public static void serieSuma() {
Scanner sc = new Scanner(System.in);
System.out.println("Número: ");
int numero = sc.nextInt();
sc.close();
int suma = 0;
for (int i = 0; i <= numero; i++) {
suma += i;
}
System.out.printf("Suma de los %d primeros números = %d", numero, suma);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment