Skip to main content
Commonmark migration
Source Link

#MATL, 20 bytes

MATL, 20 bytes

FT+"@:qtPXnosV47]xhh 

This uses the characterization in terms of binomial coefficients given in the OEIS page.

The algorithm works in theory for all numbers, but in practice it is limited by MATL's numerical precision, and so it doesn't work for large entries. The result is accurate for inputs up to 20 at least.

Try it online!

Explanation

FT+ % Implicitly take input n. Add [0 1] element-wise. Gives [n n+1] " % For each k in [n n+1] @:q % Push range [0 1 ... k-1] tP % Duplicate and flip: push [k-1 ... 1 0] Xn % Binomial coefficient, element-wise. Gives an array os % Number of odd entries in that array V % Convert from number to string 47 % Push 47, which is ASCII for '\' ] % End for each x % Remove second 47 hh % Concatenate horizontally twice. Automatically transforms 47 into '\' % Implicitly display 

#MATL, 20 bytes

FT+"@:qtPXnosV47]xhh 

This uses the characterization in terms of binomial coefficients given in the OEIS page.

The algorithm works in theory for all numbers, but in practice it is limited by MATL's numerical precision, and so it doesn't work for large entries. The result is accurate for inputs up to 20 at least.

Try it online!

Explanation

FT+ % Implicitly take input n. Add [0 1] element-wise. Gives [n n+1] " % For each k in [n n+1] @:q % Push range [0 1 ... k-1] tP % Duplicate and flip: push [k-1 ... 1 0] Xn % Binomial coefficient, element-wise. Gives an array os % Number of odd entries in that array V % Convert from number to string 47 % Push 47, which is ASCII for '\' ] % End for each x % Remove second 47 hh % Concatenate horizontally twice. Automatically transforms 47 into '\' % Implicitly display 

MATL, 20 bytes

FT+"@:qtPXnosV47]xhh 

This uses the characterization in terms of binomial coefficients given in the OEIS page.

The algorithm works in theory for all numbers, but in practice it is limited by MATL's numerical precision, and so it doesn't work for large entries. The result is accurate for inputs up to 20 at least.

Try it online!

Explanation

FT+ % Implicitly take input n. Add [0 1] element-wise. Gives [n n+1] " % For each k in [n n+1] @:q % Push range [0 1 ... k-1] tP % Duplicate and flip: push [k-1 ... 1 0] Xn % Binomial coefficient, element-wise. Gives an array os % Number of odd entries in that array V % Convert from number to string 47 % Push 47, which is ASCII for '\' ] % End for each x % Remove second 47 hh % Concatenate horizontally twice. Automatically transforms 47 into '\' % Implicitly display 
added 640 characters in body
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

#MATL, 20 bytes

FT+"@:qtPXnosV47]xhh 

This uses the characterization in terms of binomial coefficients given in the OEIS page.

The algorithm works in theory for all numbers, but in practice it is limited by MATL's numerical precision, and so it doesn't work for large entries. The result is accurate for inputs up to 20 at least.

Try it online!

Explanation

FT+ % Implicitly take input n. Add [0 1] element-wise. Gives [n n+1] " % For each k in [n n+1] @:q % Push range [0 1 ... k-1] tP % Duplicate and flip: push [k-1 ... 1 0] Xn % Binomial coefficient, element-wise. Gives an array os % Number of odd entries in that array V % Convert from number to string 47 % Push 47, which is ASCII for '\' ] % End for each x % Remove second 47 hh % Concatenate horizontally twice. Automatically transforms 47 into '\' % Implicitly display 

#MATL, 20 bytes

FT+"@:qtPXnosV47]xhh 

This uses the characterization in terms of binomial coefficients given in the OEIS page.

The algorithm works in theory for all numbers, but in practice it is limited by MATL's numerical precision, and so it doesn't work for large entries. The result is accurate for inputs up to 20 at least.

Try it online!

#MATL, 20 bytes

FT+"@:qtPXnosV47]xhh 

This uses the characterization in terms of binomial coefficients given in the OEIS page.

The algorithm works in theory for all numbers, but in practice it is limited by MATL's numerical precision, and so it doesn't work for large entries. The result is accurate for inputs up to 20 at least.

Try it online!

Explanation

FT+ % Implicitly take input n. Add [0 1] element-wise. Gives [n n+1] " % For each k in [n n+1] @:q % Push range [0 1 ... k-1] tP % Duplicate and flip: push [k-1 ... 1 0] Xn % Binomial coefficient, element-wise. Gives an array os % Number of odd entries in that array V % Convert from number to string 47 % Push 47, which is ASCII for '\' ] % End for each x % Remove second 47 hh % Concatenate horizontally twice. Automatically transforms 47 into '\' % Implicitly display 
deleted 2 characters in body
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

#MATL, 20 bytes

FT+"@:qtPXnosV47]xhh 

This uses the characterization in terms of binomial coefficients given in the OEIS page. Although the

The algorithm works in theory for all numbers, but in practice it is limited by MATL's numerical precision, and so it doesn't work for large entries. The result is accurate for inputs up to 20 at least.

Try it online!

#MATL, 20 bytes

FT+"@:qtPXnosV47]xhh 

This uses the characterization in terms of binomial coefficients given in the OEIS page. Although the algorithm works in theory for all numbers, in practice it is limited by MATL's numerical precision, and so it doesn't work for large entries. The result is accurate for inputs up to 20 at least.

Try it online!

#MATL, 20 bytes

FT+"@:qtPXnosV47]xhh 

This uses the characterization in terms of binomial coefficients given in the OEIS page.

The algorithm works in theory for all numbers, but in practice it is limited by MATL's numerical precision, and so it doesn't work for large entries. The result is accurate for inputs up to 20 at least.

Try it online!

Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382
Loading