# Ultrafactorials

The ultrafactorials are a sequence of numbers which can be generated using the following function:

a(n) = n! ^ n!


The resulting values rise extremely quickly. Side note: This is entry A046882 in the OEIS. Also related are the hyperfactorials, a still quite huge, but a bit smaller sequence: A002109

Your task is to implement these numbers into your language. Your program will calculate the sum of all ultrafactorials from 0 up to inclusive n.

## Input

Your program may only take one input: a number, which resembles the last a(n) ultrafactorial to be added to the sum. The Input is assured to be positive or 0.

## Output

Your output is all up to you, as long as there's the visible sum of the numbers somewhere.

## Rules

• You can assume all integers, therefore integer input, and using integer counting loops to produce some results.

## Test cases

Input: -1
Output: Any kind of error (because -1! is undefined), or no handling at all

Input: 0
Output: 1

Input: 1
Output: 2

Input: 2
Output: 6

Input: 3
Output: 46662

# Challenge

This is , so the answer with the least length in bytes wins!

• Do we need to consider arbitrarily large integers? Or is it enough to handle the largest that the language's default data type (such as double) supports ? – Luis Mendo Dec 19 '16 at 22:46
• The conversion in-code and output is up to you, the Input will be an integer though. @LuisMendo – devRicher Dec 19 '16 at 22:51
• Changing the rules after many people have answered isn't a nice thing to do either. Please use the Sandbox as advised whenever you want to submit a challenge. – flawr Dec 20 '16 at 9:46

# Actually 11 10 bytes

1+r!;ⁿMΣ


How it works

Program takes implicit input, implicit print at EOF
1+          Add one to the input n+1
r         Create a range (0,1,..,n)
       Create a function between the two 
!       Factorialize the current stack item
;      Duplicate the current stack item
ⁿ     Power a,b from the current stack item
M  Map the function across the stack top item
Σ Sum the stack together


## Racket 54 bytes

(for/sum((i(+ 1 n)))(let((t(factorial i)))(expt t t)))


Ungolfed:

#lang racket
(require math)

(define (f n)
(for/sum ((i (+ 1 n)))
(let ((t (factorial i)))
(expt t t))))


Testing:

(f -1)
(f 0)
(f 1)
(f 2)
(f 3)


Output:

0
1
2
6
46662


# APL (Dyalog), 11 bytes

+/(*⍨∘!0,⍳)


Try it online!

This function train is equivalent to {+/*⍨!0,⍳⍵}, which is a straight forward implementation

# Japt, 8 6 bytes

òÊx_pZ


Test it

## Explantion

Implicit input of integer U
3

ò


Create an array of integers from 0 to U, inclusive.
[0,1,2,3]

Ê


Get the factorial of each integer in the array.
[1,1,2,6]

_


Map over the array.

pZ


Raise each element (p) to the power of itself (Z).
[1,1,4,46656]

x


Reduce by addition and implicitly output the result.
46662

# Perl 6, 38 bytes

{[+] map {my \a=[*] 1..$_;a**a},0..$_}


Try it online!

# 05AB1E, 8 bytes

ƒN!N!m}O
`

Try it online!