Advertisement
joseleonweb

Untitled

Aug 23rd, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class LlistaMultiples {
  4.   public static void main (String[] args) {
  5.     Scanner lector = new Scanner(System.in);
  6.     int valor;
  7.  
  8.     System.out.print("Quin és el valor de n1? ");
  9.     int n1 = lector.nextInt();
  10.     lector.nextLine();
  11.  
  12.     System.out.print("Quin és el valor de n2 (més gran que n1)? ");
  13.     int n2 = lector.nextInt();
  14.     lector.nextLine();
  15.     if (n1 < n2) {
  16.       valor = n1;
  17.       for (int i = 2; valor <= n2; i++) {
  18.         System.out.println(valor);
  19.         valor = n1 * i;
  20.       }
  21.     } else {
  22.       System.out.println("n2 no és més gran que n1!");
  23.     }
  24.   }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement