Brain-Flak , (削除) 84 (削除ここまで) 76 bytes
#Brain-Flak , (削除) 84 (削除ここまで) 76 bytes
Thanks to Wheat Wizard for golfing 8 bytes
Try it online! ##Explanation The
Explanation
The program pushes the values from 0 to n-1 to the stack replaces the top 0 and 1 with 1 and 0. Then it multiplies the top of the stack by n and adds the value below it until there is only one value remaining on the stack.
Essentially it finds the digits for the smallest number in base n that contains n different digits (for n > 1 it's always of the form 1023...(n-1)). It then calculates the number given the digits and the base.
###Annotated Code
(({})<>) # Pushes a copy of n to the right stack and switches to right stack
{(({}[()]))}{} # While the top of the stack != 0 copy the top of the stack-1
# and push it
(<{}{}>) # Discard the top two values (0 and 1 for n > 1) and push 0
((())) # Push 1 twice (second time so that the loop is works properly)
{{} # Loop while stack height > 1
( # Push...
{<({}[()])><>({})<>}{} # The top value of the stack * n
{} # Plus the value below the top of the stack
) # End push
([][()])}{} # End loop
Annotated Code
(({})<>) # Pushes a copy of n to the right stack and switches to right stack
{(({}[()]))}{} # While the top of the stack != 0 copy the top of the stack-1
# and push it
(<{}{}>) # Discard the top two values (0 and 1 for n > 1) and push 0
((())) # Push 1 twice (second time so that the loop is works properly)
{{} # Loop while stack height > 1
( # Push...
{<({}[()])><>({})<>}{} # The top value of the stack * n
{} # Plus the value below the top of the stack
) # End push
([][()])}{} # End loop
#Brain-Flak , (削除) 84 (削除ここまで) 76 bytes
Thanks to Wheat Wizard for golfing 8 bytes
Try it online!
##Explanation
The program pushes the values from 0 to n-1 to the stack replaces the top 0 and 1 with 1 and 0. Then it multiplies the top of the stack by n and adds the value below it until there is only one value remaining on the stack.
Essentially it finds the digits for the smallest number in base n that contains n different digits (for n > 1 it's always of the form 1023...(n-1)). It then calculates the number given the digits and the base.
###Annotated Code
(({})<>) # Pushes a copy of n to the right stack and switches to right stack
{(({}[()]))}{} # While the top of the stack != 0 copy the top of the stack-1
# and push it
(<{}{}>) # Discard the top two values (0 and 1 for n > 1) and push 0
((())) # Push 1 twice (second time so that the loop is works properly)
{{} # Loop while stack height > 1
( # Push...
{<({}[()])><>({})<>}{} # The top value of the stack * n
{} # Plus the value below the top of the stack
) # End push
([][()])}{} # End loop
Brain-Flak , (削除) 84 (削除ここまで) 76 bytes
Thanks to Wheat Wizard for golfing 8 bytes
Explanation
The program pushes the values from 0 to n-1 to the stack replaces the top 0 and 1 with 1 and 0. Then it multiplies the top of the stack by n and adds the value below it until there is only one value remaining on the stack.
Essentially it finds the digits for the smallest number in base n that contains n different digits (for n > 1 it's always of the form 1023...(n-1)). It then calculates the number given the digits and the base.
Annotated Code
(({})<>) # Pushes a copy of n to the right stack and switches to right stack
{(({}[()]))}{} # While the top of the stack != 0 copy the top of the stack-1
# and push it
(<{}{}>) # Discard the top two values (0 and 1 for n > 1) and push 0
((())) # Push 1 twice (second time so that the loop is works properly)
{{} # Loop while stack height > 1
( # Push...
{<({}[()])><>({})<>}{} # The top value of the stack * n
{} # Plus the value below the top of the stack
) # End push
([][()])}{} # End loop
#Brain-Flak, 84(削除) 84 (削除ここまで) 76 bytes
(({})<>){(({}[()]))}{}{}{}(()(<()>))([][()]){{}({<({}[()])><>({})<>}{}{})([][()])}{}
Try it online! Thanks to Wheat Wizard for golfing 8 bytes
(({})<>){(({}[()]))}{}(<{}{}>)((())){{}({<({}[()])><>({})<>}{}{})([][()])}{}
Try it online!
##Explanation
The program pushes the values from 0 to n-1 to the stack replaces the top 0 and 1 with 1 and 0. Then it multiplies the top of the stack by n and adds the value below it until there is only one value remaining on the stack.
Essentially it finds the digits for the smallest number in base n that contains n different digits (for n > 1 it's always of the form 1023...(n-1)). It then calculates the number given the digits and the base.
###Annotated Code
(({})<>) # Pushes a copy of n to the right stack and switches to right stack
{(({}[()]))}{} # While the top of the stack != 0 copy the top of the stack-1
# and push it
(<{}{} #>) # Discard the top two values (0 and 1 for n > 1) and push 0
(()(<()>)) # Put # Push 1 and 0 on the stacktwice (1 on topsecond time so that the loop is works properly)
([][()]){{} # # Loop while stack height > 1
( # Push...
{<({}[()])><>({})<>}{} # The top value of the stack * n
{} # Plus the value below the top of the stack
) # End push
([][()])}{} # End loop
#Brain-Flak, 84 bytes
(({})<>){(({}[()]))}{}{}{}(()(<()>))([][()]){{}({<({}[()])><>({})<>}{}{})([][()])}{}
Try it online!
##Explanation
The program pushes the values from 0 to n-1 to the stack replaces the top 0 and 1 with 1 and 0. Then it multiplies the top of the stack by n and adds the value below it until there is only one value remaining on the stack.
Essentially it finds the digits for the smallest number in base n that contains n different digits (for n > 1 it's always of the form 1023...(n-1)). It then calculates the number given the digits and the base.
###Annotated Code
(({})<>) # Pushes a copy of n to the right stack and switches to right stack
{(({}[()]))}{} # While the top of the stack != 0 copy the top of the stack-1
# and push it
{}{} # Discard the top two values (0 and 1 for n > 1)
(()(<()>)) # Put 1 and 0 on the stack (1 on top)
([][()]){{} # Loop while stack height > 1
( # Push...
{<({}[()])><>({})<>}{} # The top value of the stack * n
{} # Plus the value below the top of the stack
) # End push
([][()])}{} # End loop
#Brain-Flak, (削除) 84 (削除ここまで) 76 bytes
Thanks to Wheat Wizard for golfing 8 bytes
(({})<>){(({}[()]))}{}(<{}{}>)((())){{}({<({}[()])><>({})<>}{}{})([][()])}{}
Try it online!
##Explanation
The program pushes the values from 0 to n-1 to the stack replaces the top 0 and 1 with 1 and 0. Then it multiplies the top of the stack by n and adds the value below it until there is only one value remaining on the stack.
Essentially it finds the digits for the smallest number in base n that contains n different digits (for n > 1 it's always of the form 1023...(n-1)). It then calculates the number given the digits and the base.
###Annotated Code
(({})<>) # Pushes a copy of n to the right stack and switches to right stack
{(({}[()]))}{} # While the top of the stack != 0 copy the top of the stack-1
# and push it
(<{}{}>) # Discard the top two values (0 and 1 for n > 1) and push 0
((())) # Push 1 twice (second time so that the loop is works properly)
{{} # Loop while stack height > 1
( # Push...
{<({}[()])><>({})<>}{} # The top value of the stack * n
{} # Plus the value below the top of the stack
) # End push
([][()])}{} # End loop
#Brain-Flak, 84 bytes
(({})<>){(({}[()]))}{}{}{}(()(<()>))([][()]){{}({<({}[()])><>({})<>}{}{})([][()])}{}
Try it online!
##Explanation
The program pushes the values from 0 to n-1 to the stack replaces the top 0 and 1 with 1 and 0. Then it multiplies the top of the stack by n and adds the value below it until there is only one value remaining on the stack.
Essentially it finds the digits for the smallest number in base n that contains n different digits (for n > 1 it's always of the form 1023...(n-1)). It then calculates the number given the digits and the base.
###Annotated Code
(({})<>) # Pushes a copy of n to the right stack and switches to right stack
{(({}[()]))}{} # While the top of the stack != 0 copy the top of the stack-1
# and push it
{}{} # Discard the top two values (0 and 1 for n > 1)
(()(<()>)) # Put 1 and 0 on the stack (1 on top)
([][()]){{} # Loop while stack height > 1
( # Push...
{<({}[()])><>({})<>}{} # The top value of the stack * n
{} # Plus the value below the top of the stack
) # End push
([][()])}{} # End loop