# Zero to the zero power

Zero to the zero power
You are encouraged to solve this task according to the task description, using any language you may know.

Some programming languages are not exactly consistent   (with other programming languages)   when   raising zero to the zeroth power:     00

Show the results of raising   zero   to the   zeroth   power.

If your computer language objects to     0**0     or     0^0     at compile time,   you may also try something like:

``` x = 0
y = 0
z = x**y
say  'z='  z
```

Show the result here.
And of course use any symbols or notation that is supported in your computer language for exponentiation.

## 8th

` 0 0 ^ . `
Output:

1

## AutoHotkey

`MsgBox % 0 ** 0`
Output:
`1`

`with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Long_Integer_Text_IO,  Ada.Long_Long_Integer_Text_IO, Ada.Float_Text_IO, Ada.Long_Float_Text_IO,  Ada.Long_Long_Float_Text_IO;use  Ada.Text_IO, Ada.Integer_Text_IO, Ada.Long_Integer_Text_IO,  Ada.Long_Long_Integer_Text_IO, Ada.Float_Text_IO, Ada.Long_Float_Text_IO,  Ada.Long_Long_Float_Text_IO; procedure Test5 is    I    : Integer           := 0;   LI   : Long_Integer      := 0;   LLI  : Long_Long_Integer := 0;   F    : Float             := 0.0;   LF   : Long_Float        := 0.0;   LLF  : Long_Long_Float   := 0.0;   Zero : Natural           := 0; begin   Put ("Integer           0^0 = ");    Put (I ** Zero, 2);   New_Line;   Put ("Long Integer      0^0 = ");   Put (LI ** Zero, 2);  New_Line;   Put ("Long Long Integer 0^0 = ");   Put (LLI ** Zero, 2); New_Line;   Put ("Float           0.0^0 = ");              Put (F ** Zero);   New_Line;   Put ("Long Float      0.0^0 = ");         Put (LF ** Zero);  New_Line;   Put ("Long Long Float 0.0^0 = ");    Put (LLF ** Zero); New_Line;end Test5; `
Output:
```Integer           0^0 =  1
Long Integer      0^0 =  1
Long Long Integer 0^0 =  1
Float           0.0^0 =  1.00000E+00
Long Float      0.0^0 =  1.00000000000000E+00
Long Long Float 0.0^0 =  1.00000000000000000E+00
```

## ALGOL 68

Works with: ALGOL 68G version Any - tested with release 2.6.win32
`print( ( 0 ^ 0, newline ) ) `
Output:
```         +1
```

## APL

`      0*01`

## Applesoft BASIC

```]? 0^0
1```

## AWK

` # syntax: GAWK -f ZERO_TO_THE_ZERO_POWER.AWKBEGIN {    print(0 ^ 0)    exit(0)} `
Output:
```1
```

## BaCon

`PRINT POW(0, 0)`
Output:
```prompt\$ ./zerotothezero
1```

```0 ^ 0
1```

## Befunge

Befunge-93 doesn't have explicit support for exponentiation, but there are a couple of fingerprint extensions for Befunge-98 which add that functionality. The example below makes use of the FPDP fingerprint (double precision floating point).

Note that the result is potentially dependent on the underlying language of the interpreter, but all those tested so far have returned 1. Interpreters that don't support Befunge-98, or don't support this fingerprint, should just terminate (possibly with a warning).

`"PDPF"4#@(0F0FYP)@`
Output:
`1.000000`

`0^0`
Output:
`1`

## Burlesque

` blsq ) 0.0 0.0?^1.0blsq ) 0 0?^1 `

## BBC BASIC

`      PRINT 0^0`
Output:
```1
```

## C

Works with: C99

This example uses the standard `pow` function in the math library. 0^0 is given as 1.

`#include <stdio.h>#include <math.h>#include <complex.h> int main(){	printf("0 ^ 0 = %f\n", pow(0,0));        double complex c = cpow(0,0);	printf("0+0i ^ 0+0i = %f+%fi\n", creal(c), cimag(c));	return 0;}`
Output:
```0 ^ 0 = 1.000000
0+0i ^ 0+0i = nan+nani
```

## C++

`#include <iostream>#include <cmath>#include <complex> int main(){  std::cout << "0 ^ 0 = " << std::pow(0,0) << std::endl;  std::cout << "0+0i ^ 0+0i = " <<    std::pow(std::complex<double>(0),std::complex<double>(0)) << std::endl;  return 0;}`
Output:
```0 ^ 0 = 1
0+0i ^ 0+0i = (nan,nan)
```

## C#

`using System; namespace ZeroToTheZeroeth{    class Program    {        static void Main(string[] args)        {            double k = Math.Pow(0, 0);            Console.Write("0^0 is {0}", k);                   }    }}`
Output:
```0^0 is 1
```

## Clojure

```user=> (use 'clojure.math.numeric-tower)
user=> (expt 0 0)
1

; alternative java-interop route:
user=> (Math/pow 0 0)
1.0
```

## COBOL

`identification division.program-id. zero-power-zero-program.data division.working-storage section.77  n                         pic 9.procedure division.    compute n = 0**0.    display n upon console.    stop run.`
Output:
`1`

## ColdFusion

### Classic tag based CFML

` <cfset zeroPowerTag = 0^0><cfoutput>"#zeroPowerTag#"</cfoutput> `
Output:
```"1"
```

### Script Based CFML

`<cfscript>  zeroPower = 0^0;  writeOutput( zeroPower );</cfscript>`
Output:
```1
```

## Common Lisp

```> (expt 0 0)
1```

## D

`void main() {    import std.stdio, std.math, std.bigint, std.complex;     writeln("Int:     ", 0 ^^ 0);    writeln("Ulong:   ", 0UL ^^ 0UL);    writeln("Float:   ", 0.0f ^^ 0.0f);    writeln("Double:  ", 0.0 ^^ 0.0);    writeln("Real:    ", 0.0L ^^ 0.0L);    writeln("pow:     ", pow(0, 0));    writeln("BigInt:  ", 0.BigInt ^^ 0);    writeln("Complex: ", complex(0.0, 0.0) ^^ 0);}`
Output:
```Int:     1
Ulong:   1
Float:   1
Double:  1
Real:    1
pow:     1
BigInt:  1
Complex: 1+0i```

0 0^p

Output:
```1
```

## EchoLisp

` ;; trying the 16 combinations;; all return the integer 1 (lib 'bigint)(define zeroes '(integer: 0 inexact=float: 0.000 complex: 0+0i bignum: #0))(for* ((z1 zeroes) (z2 zeroes)) (write (expt z1 z2)))    →  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  `

## Eiffel

`print (0^0)`
Output:
`1`

## Elena

`import extensions. program =[    console printLine("0^0 is ",0 power:0).].`
Output:
```0^0 is 0
```

## Elixir

Elixir uses Erlang's `:math` for power operations and can handle zero to the zero power.

` :math.pow(0,0) `
Output:

1.0

## ERRE

` .....PRINT(0^0)..... `
Output:
``` 1
```

## F#

In the REPL:

```> let z = 0.**0.;;

val z : float = 1.0```

## Factor

`USING: math.functions.private ; ! ^complex0 0 ^C{ 0 0 } C{ 0 0 } ^complex`
Output:
```--- Data stack:
NAN: 8000000000000
C{ NAN: 8000000000000 NAN: 8000000000000 }```

## Forth

`0e 0e f** f.`
Output:
`1.`

Of course in an embedded program we would be tempted to "pre-calculate" the answer :-)

`: ^0     DROP  1 ;`
Output:
```0 ^0 . 1 ok
```

## Fortran

` program zerodouble precision :: i, jdouble complex :: z1, z2i = 0.0D0j = 0.0D0z1 = (0.0D0,0.0D0)z2 = (0.0D0,0.0D0)write(*,*) 'When integers are used, we have 0^0 = ', 0**0write(*,*) 'When double precision numbers are used, we have 0.0^0.0 = ', i**jwrite(*,*) 'When complex numbers are used, we have (0.0+0.0i)^(0.0+0.0i) = ', z1**z2end program `
Output:
``` When integers are used, we have 0^0 =            1
When double precision numbers are used, we have 0.0^0.0 =    1.0000000000000000
When complex numbers are used, we have (0.0+0.0i)^(0.0+0.0i) =  (             NaN,             NaN)
```

## FreeBASIC

`' FB 1.05.0 Win64 Print "0 ^ 0 ="; 0 ^ 0Sleep`
Output:
```0 ^ 0 = 1
```

## Gambas

`Public Sub Main() Print 0 ^ 0 End`

Output:

```1
```

## Go

Go does not have an exponentiation operator but has functions in the standard library for three types, float64, complex128, and big.Int. As of Go 1.3, all are documented to return 1.

`package main import (    "fmt"    "math"    "math/big"    "math/cmplx") func main() {    fmt.Println("float64:    ", math.Pow(0, 0))    var b big.Int    fmt.Println("big integer:", b.Exp(&b, &b, nil))    fmt.Println("complex:    ", cmplx.Pow(0, 0))}`
Output:
```float64:     1
big integer: 1
complex:     (1+0i)
```

## FutureBasic

` include "ConsoleWindow" print 0^0 `

Output:

```1
```

## Groovy

Translation of: Java

Test:

`println 0**0`
Output:
`1`

`import Data.Complex main = do  print \$ 0 ^ 0  print \$ 0.0 ^ 0  print \$ 0 ^^ 0  print \$ 0 ** 0  print \$ (0 :+ 0) ^ 0  print \$ (0 :+ 0) ** (0 :+ 0)`
Output:
```1
1.0
1.0
1.0
1.0 :+ 0.0
NaN :+ NaN
```

## Icon and Unicon

"Works" in both languages:

`procedure main()    write(0^0)end`
Output:
```->z2z

Run-time error 204
File z2z.icn; Line 2
real overflow, underflow, or division by zero
Traceback:
main()
{0 ^ 0} from line 2 in z2z.icn
->
```

## J

`   0 ^ 01`

## Java

`System.out.println(Math.pow(0, 0));`
Output:
`1.0`

## JavaScript

Works with: Node.js

In interactive mode:

`> Math.pow(0, 0);1`

## jq

jq version 1.4 does not have a builtin "power" function. If it were to be defined using the exp and log builtins as 'log * y | exp', then 0 | power(0) would yield null, and therefore a definition that makes a special case of 0^0 should be considered, e.g. along the following lines:

`def power(y): y as \$y | if \$y == 0 then 1 elif . == 0 then 0 else log * \$y | exp end;`

This definition will however be unsatisfactory for many purposes because it does not maintain precision for integer values of the input (.) and y.

## Julia

Try all combinations of complex, float, rational, integer and boolean.

` zs = Any[zero(Complex),         zero(FloatingPoint),         zero(Rational),         zero(Integer),         zero(Bool)] for i in zs, j in zs    println(i, "^", j, " = ", i^j, " (", typeof(i^j), ")")end `

Note that if `zs` is not annotated as being of type `Any` all of the zeros will be promoted to complex when `zs` is constructed.

Output:
```0 + 0im^0 + 0im = 1.0 + 0.0im (Complex{Float64})
0 + 0im^0.0 = 1.0 + 0.0im (Complex{Float64})
0 + 0im^0//1 = 1.0 + 0.0im (Complex{Float64})
0 + 0im^0 = 1 + 0im (Complex{Int64})
0 + 0im^false = 1 + 0im (Complex{Int64})
0.0^0 + 0im = 1.0 + 0.0im (Complex{Float64})
0.0^0.0 = 1.0 (Float64)
0.0^0//1 = 1.0 (Float64)
0.0^0 = 1.0 (Float64)
0.0^false = 1.0 (Float64)
0//1^0 + 0im = 1.0 + 0.0im (Complex{Float64})
0//1^0.0 = 1.0 (Float64)
0//1^0//1 = 1.0 (Float64)
0//1^0 = 1//1 (Rational{Int64})
0//1^false = 1//1 (Rational{Int64})
0^0 + 0im = 1.0 + 0.0im (Complex{Float64})
0^0.0 = 1.0 (Float64)
0^0//1 = 1.0 (Float64)
0^0 = 1 (Int64)
0^false = 1 (Int64)
false^0 + 0im = 1.0 + 0.0im (Complex{Float64})
false^0.0 = 1.0 (Float64)
false^0//1 = 1.0 (Float64)
false^0 = true (Bool)
false^false = true (Bool)
```

## Kotlin

`// version 1.0.6 fun main(args: Array<String>) {   println("0 ^ 0 = \${Math.pow(0.0, 0.0)}")}`
Output:
```0 ^ 0 = 1.0
```

## Lua

No need to try different data types or with / without decimal points as all numbers in Lua are stored in double-precision floating-point format.

`print(0^0)`
Output:
`1`

## Maple

`0^0`
Output:
`1`

However, for consistency with IEEE-754 numerics, we also have a NaN result for the equivalent floating-point exponentiation:

`0^0.0`
Output:
`Float(undefined)`

## Mathematica

`0^0`
Output:
`Indeterminate`

## MATLAB / Octave

`0^0complex(0,0)^0`
Output:
```1
1```

## Mercury

`:- module zero_to_the_zero_power.:- interface. :- import_module io. :- pred main(io::di, io::uo) is det. :- implementation. :- import_module float, int, integer, list, string. main(!IO) :-   io.format("    int.pow(0, 0) = %d\n", [i(pow(0, 0))], !IO),   io.format("integer.pow(zero, zero) = %s\n",        [s(to_string(pow(zero, zero)))], !IO),   io.format("  float.pow(0.0, 0) = %.1f\n", [f(pow(0.0, 0))], !IO). :- end_module zero_to_the_zero_power.`
Output:
```    int.pow(0, 0) = 1
integer.pow(zero, zero) = 1
float.pow(0.0, 0) = 1.0```

## МК-61/52

`Сx	^	x^y	С/П`

The result is error message.

## NetRexx

`x=0Say '0**0='||x**x`
Output:
`0**0=1`

## NewLISP

`(pow 0 0)`
Output:
`1`

## Nim

`import math echo pow(0, 0)`
Output:
`1.0`

## OCaml

In the interpreter:

```# 0.0 ** 0.0;;
- : float = 1.
# Complex.pow Complex.zero Complex.zero;;
- : Complex.t = {Complex.re = nan; Complex.im = nan}
# open Num;;
# Int 0 **/ Int 0;;
- : Num.num = Int 1
```

## Oforth

`0 0 pow println`
Output:
```1
```

## ooRexx

`/*********************************************************************** 21.04.2014 Walter Pachl**********************************************************************/Say 'rxCalcpower(0,0)  ->' rxCalcpower(0,0)Say '0**0              ->' 0**0::requires rxmath library`
Output:
```rxCalcpower(0,0)  -> 1
0**0              -> 1
```

`0^0`
Output:
`%1 = 1`

## Pascal

Works with: Free Pascal
Library: math
`program ZToZ;uses  math;begin  write('0.0 ^ 0 :',IntPower(0.0,0):4:2);  writeln('   0.0 ^ 0.0 :',Power(0.0,0.0):4:2);end.`
output
`0.0 ^ 0 :1.00   0.0 ^ 0.0 :1.00`

## Perl

`print 0 ** 0, "\n"; use Math::Complex; print cplx(0,0) ** cplx(0,0), "\n";`
Output:
```1
1
```

## Perl 6

Works with: Rakudo version 2016.11
`say '    type         n      n**n  exp(n,n)';say '--------  --------  --------  --------'; for 0, 0.0, FatRat.new(0), 0e0, 0+0i {    printf "%8s  %8s  %8s  %8s\n", .^name, \$_, \$_**\$_, exp(\$_,\$_);}`
Output:
```    type         n      n**n  exp(n,n)
--------  --------  --------  --------
Int         0         1         1
Rat         0         1         1
FatRat         0         1         1
Num         0         1         1
Complex      0+0i      1+0i      1+0i
```

## Phix

Fair enough, I have no strong opinions on this matter, so I have just removed the test/error that was present in previous versions. Should you for any reason want to change it back, just edit builtins/VM/pPower.e, search for the two mods dated 3/11/15 (32 and 64 bit, both are two lines, test eax/rax; jz :e102cr0tple0), save and rebuild (run "p -c p"), which should take less than 10 seconds.

`?power(0,0)`
Output:
`1`

## PHP

`<?phpecho pow(0,0);echo 0 ** 0; // PHP 5.6+ only?>`
Output:
```1
1
```

## PicoLisp

` (** 0 0) `
Output:

1

## PL/I

` zhz: Proc Options(Main); Dcl a dec float(10) Init(1); Dcl b dec float(10) Init(0); Put skip list('1**0=',a**b); Put skip list('0**1=',b**a); Put skip list('0**0=',b**b); End;`
Output:
```1**0=                    1.000000000E+0000
0**1=                    0.000000000E+0000
0**0=
IBM0682I  ONCODE=1553  X in EXPONENT(X) was invalid.
At offset +0000025B in procedure with entry ZHZ
```

## PowerShell

`[math]::pow(0,0)`

## PureBasic

` If OpenConsole()  PrintN("Zero to the zero power is " + Pow(0,0))  PrintN("")  PrintN("Press any key to close the console")  Repeat: Delay(10) : Until Inkey() <> ""  CloseConsole()EndIf `
Output:
```Zero to the zero power is 1
```

## Python

`from decimal import Decimalfrom fractions import Fractionfor n in (Decimal(0), Fraction(0, 1), complex(0), float(0), int(0)):	try:		n1 = n**n	except:		n1 = '<Raised exception>'	try:		n2 = pow(n, n)	except:		n2 = '<Raised exception>'	print('%8s: ** -> %r; pow -> %r' % (n.__class__.__name__, n1, n2))`
Output:
``` Decimal: ** -> '<Raised exception>'; pow -> '<Raised exception>'
Fraction: ** -> Fraction(1, 1); pow -> Fraction(1, 1)
complex: ** -> (1+0j); pow -> (1+0j)
float: ** -> 1.0; pow -> 1.0
int: ** -> 1; pow -> 1
```

## R

`print(0^0)`
Output:
`1`

## Racket

`#lang racket;; as many zeros as I can think of...(define zeros (list               0  ; unspecified number type               0. ; hinted as float               #e0 ; explicitly exact               #i0 ; explicitly inexact               0+0i ; exact complex               0.+0.i ; float inexact               ))(for*((z zeros) (p zeros))  (printf "(~a)^(~a) = ~s~%" z p  (with-handlers [(exn:fail:contract:divide-by-zero? exn-message)]    (expt z p))))`
Output:
```(0)^(0) = 1
(0)^(0.0) = 1.0
(0)^(0) = 1
(0)^(0.0) = 1.0
(0)^(0) = 1
(0)^(0.0+0.0i) = "expt: undefined for 0 and 0.0+0.0i"
(0.0)^(0) = 1
(0.0)^(0.0) = 1.0
(0.0)^(0) = 1
(0.0)^(0.0) = 1.0
(0.0)^(0) = 1
(0.0)^(0.0+0.0i) = +nan.0+nan.0i
(0)^(0) = 1
(0)^(0.0) = 1.0
(0)^(0) = 1
(0)^(0.0) = 1.0
(0)^(0) = 1
(0)^(0.0+0.0i) = "expt: undefined for 0 and 0.0+0.0i"
(0.0)^(0) = 1
(0.0)^(0.0) = 1.0
(0.0)^(0) = 1
(0.0)^(0.0) = 1.0
(0.0)^(0) = 1
(0.0)^(0.0+0.0i) = +nan.0+nan.0i
(0)^(0) = 1
(0)^(0.0) = 1.0
(0)^(0) = 1
(0)^(0.0) = 1.0
(0)^(0) = 1
(0)^(0.0+0.0i) = "expt: undefined for 0 and 0.0+0.0i"
(0.0+0.0i)^(0) = 1
(0.0+0.0i)^(0.0) = 1.0+0.0i
(0.0+0.0i)^(0) = 1
(0.0+0.0i)^(0.0) = 1.0+0.0i
(0.0+0.0i)^(0) = 1
(0.0+0.0i)^(0.0+0.0i) = +nan.0+nan.0i```

## REXX

`/*REXX program shows the results of  raising zero  to the  zeroth power.*/say  '0 ** 0  (zero to the zeroth power) ───► '    0**0`

using PC/REXX
using Personal REXX
using REGINA
using ooRexx

Output:
```0 ** 0  (zero to the zeroth power) ───►  1
```

using R4

Output:
```Error 26 : Invalid whole number (SYNTAX)
Information: 0 ** 0 is undefined
Error occurred in statement# 2
Statement source: say '0 ** 0  (zero to the zeroth power) ───► ' 0**0
Statement context: C:\ZERO_TO0.REX, procedure: ZERO_TO0
```

using ROO

Output:
```Error 26 : Invalid whole number (SYNTAX)
Information: 0 ** 0 is undefined
Error occurred in statement# 2
Statement source: say '0 ** 0  (zero to the zeroth power) ───► ' 0**0
Statement context: C:\ZERO_TO0.REX, procedure: ZERO_TO0
```

## Ring

` x = 0y = 0z = pow(x,y)see "z=" + z + nl   # z=1 `

## Ruby

`require 'bigdecimal' [0, 0.0, Complex(0), Rational(0), BigDecimal.new("0")].each do |n|  printf "%10s: ** -> %s\n" % [n.class, n**n]end`
Output:
```    Fixnum: ** -> 1
Float: ** -> 1.0
Complex: ** -> 1+0i
Rational: ** -> 1/1
BigDecimal: ** -> 0.1E1
```

## Rust

`fn main() {    println!("{}",0u32.pow(0));}`
Output:
`1`

## S-lang

`print(0^0);`
Output:
`1.0`

## Scala

Library: Scala
`  assert(math.pow(0, 0) == 1, "Scala blunder, should go back to school !")`

## Scheme

`(display (expt 0 0)) (newline)(display (expt 0.0 0.0)) (newline)(display (expt 0+0i 0+0i)) (newline)`
Output:
```1
1.0
1.0```

## Seed7

`\$ include "seed7_05.s7i";  include "float.s7i";  include "complex.s7i"; const proc: main is func  begin    writeln("0      ** 0   = " <& 0 ** 0);    writeln("0.0    ** 0   = " <& 0.0 ** 0);    writeln("0.0    ** 0.0 = " <& 0.0 ** 0.0);    writeln("0.0+0i ** 0   = " <& complex(0.0) ** 0);  end func; `
Output:
```0      ** 0   = 1
0.0    ** 0   = 1.0
0.0    ** 0.0 = 1.0
0.0+0i ** 0   = 1.0+0.0i
```

## Sidef

`[0, Complex(0, 0)].each {|n|    say n**n}`
Output:
```1
1
```

Taking the 0'th root of a number and raising it back to the zero power, we also get a 1:

`say 0.root(0).pow(0)       # => 1say ((0**(1/0))**0)        # => 1`

## Smalltalk

` 0 raisedTo: 0 0.0 raisedTo: 0.0  `
Output:
```1
1.0
```

## smart BASIC

`PRINT 0^0`
Output:
```1
```

## SQL

` SQL> SELECT POWER(0,0) FROM dual; `
Output:
```POWER(0,0)
----------
1
```

## Standard ML

In the interpreter:

```- Math.pow (0.0, 0.0);
val it = 1.0 : real
```

## Stata

`. display 0^01`

## Swift

`import Darwinprint(pow(0.0,0.0))`
Output:
`1.0`

## Tcl

Interactively…

`% expr 0**01% expr 0.0**0.01.0`

## uBasic/4tH

`Print 0^0`
Output:
```1

0 OK, 0:9```

## Ursa

Cygnus/X Ursa is written in Java, and as a result returns 1.0 when raising 0 to the 0.

`> out (pow 0 0) endl console1.0`

## VBScript

`WScript.Echo 0 ^ 0`
Output:
`1`

## XLISP

`XLISP 3.3, September 6, 2002 Copyright (c) 1984-2002, by David Betz[1] (expt 0 0) 1[2] `

## zkl

`(0.0).pow(0)  //--> 1.0var BN=Import("zklBigNum"); // big intsBN(0).pow(0) //--> 1`