humble number in java code

Solutions on MaxInterview for humble number in java code by the best coders in the world

showing results for - "humble number in java code"
Elena
22 Nov 2017
1import java.util.HashSet;
2public class Main
3{
4	public static void main(String[] args) {
5		int n = 21;
6		humble(n);
7	}
8	public static void humble(int n){
9	    HashSet<Integer> h = new HashSet<>() ;
10	    for(int i=2;i<=n;i++){
11	        while(n%i == 0){
12	            h.add(i);
13	            n = n/i;
14	            if(i != 2 && i != 3 && i!=5 && i!=7 ){
15	                System.out.print("not ");
16	            }
17	        }
18	    }
19	    System.out.println("humble");
20	}
21}
22