5.12 (Find the smallest n such that n2>12,000) Use a while loop to find the smallest
integer n such that n2 is greater than 12,000.
public class ProgrammingEx5_12 { public static void main(String[] args) { int n = 1; while (Math.pow(n, 2) <= 12000) { n++; } System.out.println("The n is " + n); System.out.println("The n^2 is " + Math.pow(n, 2)); } }
No comments:
Post a Comment