The lines written request YORK happy ugly N-th number in Java

The so-called ugly number, which is only capable of being divisible by 2 or 3 or 5, we used the number 1 as the first ugly, ugly seek the n-th number.

The basic idea can be viewed prove safety offer 34 questions.


Java code to achieve:


public static int getChouShu(int nums) {
		int index = 1;
		int choushu = 1;
		
		while (nums > index) {
			choushu ++ ;
			if (choushu % 2 == 0 || choushu % 3 == 0 || choushu % 5 == 0) {
				index ++ ;
			}
			
		}
		
		return choushu;
	}


- - and articles on the same topic but I also borrow methods that bloggers look quite complicated - - This question is crucial also wrong see the joke
Published 16 original articles · won praise 21 · views 30000 +

Guess you like

Origin blog.csdn.net/q690080900/article/details/78001731