Skip to content

Instantly share code, notes, and snippets.

@ofou
Last active September 2, 2016 02:59
Show Gist options
  • Save ofou/f6384b1fbc719981f17890e5fbe26495 to your computer and use it in GitHub Desktop.
Save ofou/f6384b1fbc719981f17890e5fbe26495 to your computer and use it in GitHub Desktop.
Print multiples of a given positive number and error message if negative
import java.util.Scanner;
/**
* Created by @ofrancisco on 9/1/16.
*/
public class Main {
public static void main(String[] args) {
Scanner lector = new Scanner(System.in);
int numeroUsuario = lector.nextInt();
if(numeroUsuario<0){
System.out.println("Error. Ingrese un numero positivo");
}
else{
for(int contador=1 ; contador<numeroUsuario; contador++ ){
if(numeroUsuario%contador == 0){
System.out.println(contador);
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment