Guest User

Untitled

a guest
Feb 19th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class ishrat {
  5.     public static void main(String args[]){
  6.         Scanner console = new Scanner(System.in);
  7.        
  8.         System.out.print("Oppgi øvre grense: ");
  9.         int øvreGrense = console.nextInt();
  10.        
  11.         printNumbersIncreasing (øvreGrense);
  12.     }
  13.        
  14.     static void printNumbersIncreasing (int øvreGrense) {     
  15.         int printNumbers=1;
  16.        
  17.         for (int i=1;i<=printNumbers; i++){
  18.             if(printNumbers <= øvreGrense){
  19.                 for(int j=1;j<=i;j++){
  20.                     if (printNumbers <= øvreGrense) {
  21.                         System.out.printf("%" + i + "d", printNumbers);
  22.                     printNumbers++;
  23.                     }
  24.                 }
  25.                 System.out.println();
  26.             }
  27.         }
  28.     }
  29. }
Add Comment
Please, Sign In to add comment