-
Notifications
You must be signed in to change notification settings - Fork 161
/
powx-n.md
30 lines (22 loc) · 930 Bytes
/
powx-n.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<p>Implement <a href="http://www.cplusplus.com/reference/valarray/pow/" target="_blank">pow(<em>x</em>, <em>n</em>)</a>, which calculates <em>x</em> raised to the power <em>n</em> (x<sup><span style="font-size:10.8333px">n</span></sup>).</p>
<p><strong>Example 1:</strong></p>
<pre>
<strong>Input:</strong> 2.00000, 10
<strong>Output:</strong> 1024.00000
</pre>
<p><strong>Example 2:</strong></p>
<pre>
<strong>Input:</strong> 2.10000, 3
<strong>Output:</strong> 9.26100
</pre>
<p><strong>Example 3:</strong></p>
<pre>
<strong>Input:</strong> 2.00000, -2
<strong>Output:</strong> 0.25000
<strong>Explanation:</strong> 2<sup>-2</sup> = 1/2<sup>2</sup> = 1/4 = 0.25
</pre>
<p><strong>Note:</strong></p>
<ul>
<li>-100.0 < <em>x</em> < 100.0</li>
<li><em>n</em> is a 32-bit signed integer, within the range [−2<sup>31</sup>, 2<sup>31 </sup>− 1]</li>
</ul>