Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class LukusarjanSumma {
  4.  
  5. public static void main(String[] args) {
  6. Scanner lukija = new Scanner(System.in);
  7.  
  8. System.out.print("Mihin asti? ");
  9. int n = Integer.valueOf(lukija.nextLine());
  10.  
  11. int summa = 0;
  12. int luku = 1;
  13. while (luku <= n) {
  14. summa += luku;
  15. luku++;
  16. }
  17.  
  18. System.out.println("Summa on " + summa);
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement