Logo

Programming-Idioms

Compute and print a^b, and a^n, where a and b are floating point numbers and n is an integer.
New implementation

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating material.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
#include <stdio.h>
#include <math.h>
printf("%f %f", pow(a, b), pow(a, n));
  print *,a**b, a**n
import static java.lang.Math.pow;
import static java.lang.System.out;
out.println(pow(a, b));
out.println(pow(a, n));
math
writeln('a^b=',power(a,b));
writeln('a^n=',power(a,n));
use feature 'say';
my ($a, $b, $n) = (4.0, 0.5, 3);

say $a**$b;  # prints 2
say $a**$n;  # prints 64
print(a ** b, a ** n)
puts a ** b, a ** n