jsp에서 Math.pow사용하기

2016. 8. 30. 17:39프로그래밍/jsp

반응형

<body>

<%!

int cube(int x) {

return (int)Math.pow(x,3); // return x * x * x;

}

%>

 <h2>2세제곱 = <%=cube(2) %></h2><br>

 <h2>3세제곱 = <%=cube(3) %></h2><br> 

 <h2>4세제곱 = <%=cube(4) %></h2><br> 

 <h2>5세제곱 = <%=cube(5) %></h2><br> 

 <h2>6세제곱 = <%=cube(6) %></h2><br>

</body>


Math.pow를 이용하면 쉽게 2^3, 3^3... 을 구할 수 있다! 

반응형