Post History
#7: Post edited
Reduce over the range [1..n] [FINALIZED]
# Task I often need to find the factorial of a number or the sum of all numbers up to a number when cheating on math tests. To help me with this, your task is to write $F$, a generalized version of those functions: $$F(n) = 1 * 2 * \space ... \space * (n-1) * n$$ Please note that the operator $ * $ does not necessarily represent multiplication here, but stands for a [commutative](https://en.wikipedia.org/wiki/Commutative_property), [associative](https://en.wikipedia.org/wiki/Associative_property) operator that will be an input to your program/function. This means that $a * b$ is the same as $b * a$, and $a * (b * c)$ is the same as $(a * b) * c$. Its inputs are positive integers, and its outputs are integers. # Rules - $n$ will be a positive integer. - $*$ is a binary function/operator that can be taken in any convenient format, including but not limited to: - A function object - A function pointer - An object with a method with a specific name (e.g. Java's [`BiFunction`](https://docs.oracle.com/javase/8/docs/api/java/util/function/BiFunction.html[]())) - A string that can be evaluated to get a function - $*$ is a blackbox function. That means that you will not be able to examine it to see how it works; all you can do is feed it two positive integers and get an integer back. - The output of your function will be an integer (not necessarily positive). - This is <a class="badge is-tag">code golf</a>, so shortest code in bytes wins! # Testcases ``` f | n | F(f, n) Add | 1 | 1 Add | 5 | 15 Multiply | 1 | 1 Multiply | 5 | 120 XOR | 1 | 1 XOR | 2 | 3 XOR | 5 | 1 XOR | 10 | 11 ``` Questions: - Interesting enough? Is a vanilla factorial better? - Are the tags okay? - Needs more testcases? - Input rules okay?
#5: Post edited
- # Task
- I often need to find the factorial of a number or the sum of all numbers up to a number when cheating on math tests. To help me with this, your task is to write $F$, a generalized version of those functions:
$$F(n) = 1 * 2 * ... * (n-1) * n$$- Please note that the operator $ * $ does not necessarily represent multiplication here, but stands for a [commutative](https://en.wikipedia.org/wiki/Commutative_property), [associative](https://en.wikipedia.org/wiki/Associative_property) operator that will be an input to your program/function. This means that $a * b$ is the same as $b * a$, and $a * (b * c)$ is the same as $(a * b) * c$. Its inputs are positive integers, and its outputs are integers.
- # Rules
- - $n$ will be a positive integer.
- - $*$ is a binary function/operator that can be taken in any convenient format, including but not limited to:
- - A function object
- - A function pointer
- - An object with a method with a specific name (e.g. Java's [`BiFunction`](https://docs.oracle.com/javase/8/docs/api/java/util/function/BiFunction.html[]()))
- - A string that can be evaluated to get a function
- - $*$ is a blackbox function. That means that you will not be able to examine it to see how it works; all you can do is feed it two positive integers and get an integer back.
- This is [code-golf], so shortest code in bytes wins!- # Testcases
- ```
- f | n | F(f, n)
- Add | 1 | 1
- Add | 5 | 15
- Multiply | 1 | 1
- Multiply | 5 | 120
- XOR | 1 | 1
- XOR | 2 | 3
- XOR | 5 | 1
- XOR | 10 | 11
- ```
- Questions:
- - Interesting enough? Is a vanilla factorial better?
- - Are the tags okay?
- - Needs more testcases?
- - Input rules okay?
- # Task
- I often need to find the factorial of a number or the sum of all numbers up to a number when cheating on math tests. To help me with this, your task is to write $F$, a generalized version of those functions:
- $$F(n) = 1 * 2 * \space ... \space * (n-1) * n$$
- Please note that the operator $ * $ does not necessarily represent multiplication here, but stands for a [commutative](https://en.wikipedia.org/wiki/Commutative_property), [associative](https://en.wikipedia.org/wiki/Associative_property) operator that will be an input to your program/function. This means that $a * b$ is the same as $b * a$, and $a * (b * c)$ is the same as $(a * b) * c$. Its inputs are positive integers, and its outputs are integers.
- # Rules
- - $n$ will be a positive integer.
- - $*$ is a binary function/operator that can be taken in any convenient format, including but not limited to:
- - A function object
- - A function pointer
- - An object with a method with a specific name (e.g. Java's [`BiFunction`](https://docs.oracle.com/javase/8/docs/api/java/util/function/BiFunction.html[]()))
- - A string that can be evaluated to get a function
- - $*$ is a blackbox function. That means that you will not be able to examine it to see how it works; all you can do is feed it two positive integers and get an integer back.
- - The output of your function will be an integer (not necessarily positive).
- - This is <a class="badge is-tag">code golf</a>, so shortest code in bytes wins!
- # Testcases
- ```
- f | n | F(f, n)
- Add | 1 | 1
- Add | 5 | 15
- Multiply | 1 | 1
- Multiply | 5 | 120
- XOR | 1 | 1
- XOR | 2 | 3
- XOR | 5 | 1
- XOR | 10 | 11
- ```
- Questions:
- - Interesting enough? Is a vanilla factorial better?
- - Are the tags okay?
- - Needs more testcases?
- - Input rules okay?
#4: Post edited
- # Task
I often need to find the factorial or a number of the sum of all numbers up to a number when cheating on math tests. To help me with this, your task is to write $F$, a generalized version of those functions:- $$F(n) = 1 * 2 * ... * (n-1) * n$$
- Please note that the operator $ * $ does not necessarily represent multiplication here, but stands for a [commutative](https://en.wikipedia.org/wiki/Commutative_property), [associative](https://en.wikipedia.org/wiki/Associative_property) operator that will be an input to your program/function. This means that $a * b$ is the same as $b * a$, and $a * (b * c)$ is the same as $(a * b) * c$. Its inputs are positive integers, and its outputs are integers.
- # Rules
- - $n$ will be a positive integer.
- - $*$ is a binary function/operator that can be taken in any convenient format, including but not limited to:
- - A function object
- - A function pointer
- - An object with a method with a specific name (e.g. Java's [`BiFunction`](https://docs.oracle.com/javase/8/docs/api/java/util/function/BiFunction.html[]()))
- - A string that can be evaluated to get a function
- - $*$ is a blackbox function. That means that you will not be able to examine it to see how it works; all you can do is feed it two positive integers and get an integer back.
- - This is [code-golf], so shortest code in bytes wins!
- # Testcases
- ```
- f | n | F(f, n)
- Add | 1 | 1
- Add | 5 | 15
- Multiply | 1 | 1
- Multiply | 5 | 120
- XOR | 1 | 1
- XOR | 2 | 3
- XOR | 5 | 1
- XOR | 10 | 11
- ```
- Questions:
- - Interesting enough? Is a vanilla factorial better?
- - Are the tags okay?
- - Needs more testcases?
- - Input rules okay?
- # Task
- I often need to find the factorial of a number or the sum of all numbers up to a number when cheating on math tests. To help me with this, your task is to write $F$, a generalized version of those functions:
- $$F(n) = 1 * 2 * ... * (n-1) * n$$
- Please note that the operator $ * $ does not necessarily represent multiplication here, but stands for a [commutative](https://en.wikipedia.org/wiki/Commutative_property), [associative](https://en.wikipedia.org/wiki/Associative_property) operator that will be an input to your program/function. This means that $a * b$ is the same as $b * a$, and $a * (b * c)$ is the same as $(a * b) * c$. Its inputs are positive integers, and its outputs are integers.
- # Rules
- - $n$ will be a positive integer.
- - $*$ is a binary function/operator that can be taken in any convenient format, including but not limited to:
- - A function object
- - A function pointer
- - An object with a method with a specific name (e.g. Java's [`BiFunction`](https://docs.oracle.com/javase/8/docs/api/java/util/function/BiFunction.html[]()))
- - A string that can be evaluated to get a function
- - $*$ is a blackbox function. That means that you will not be able to examine it to see how it works; all you can do is feed it two positive integers and get an integer back.
- - This is [code-golf], so shortest code in bytes wins!
- # Testcases
- ```
- f | n | F(f, n)
- Add | 1 | 1
- Add | 5 | 15
- Multiply | 1 | 1
- Multiply | 5 | 120
- XOR | 1 | 1
- XOR | 2 | 3
- XOR | 5 | 1
- XOR | 10 | 11
- ```
- Questions:
- - Interesting enough? Is a vanilla factorial better?
- - Are the tags okay?
- - Needs more testcases?
- - Input rules okay?
#3: Post edited
- # Task
I often need to find the factorial of a number of the sum of all numbers up to a number when cheating on math tests. To help me with this, your task is to write $F$, a generalized version of those functions:- $$F(n) = 1 * 2 * ... * (n-1) * n$$
- Please note that the operator $ * $ does not necessarily represent multiplication here, but stands for a [commutative](https://en.wikipedia.org/wiki/Commutative_property), [associative](https://en.wikipedia.org/wiki/Associative_property) operator that will be an input to your program/function. This means that $a * b$ is the same as $b * a$, and $a * (b * c)$ is the same as $(a * b) * c$. Its inputs are positive integers, and its outputs are integers.
- # Rules
- - $n$ will be a positive integer.
- - $*$ is a binary function/operator that can be taken in any convenient format, including but not limited to:
- - A function object
- - A function pointer
- - An object with a method with a specific name (e.g. Java's [`BiFunction`](https://docs.oracle.com/javase/8/docs/api/java/util/function/BiFunction.html[]()))
- - A string that can be evaluated to get a function
- - $*$ is a blackbox function. That means that you will not be able to examine it to see how it works; all you can do is feed it two positive integers and get an integer back.
- - This is [code-golf], so shortest code in bytes wins!
- # Testcases
- ```
- f | n | F(f, n)
- Add | 1 | 1
- Add | 5 | 15
- Multiply | 1 | 1
- Multiply | 5 | 120
- XOR | 1 | 1
- XOR | 2 | 3
- XOR | 5 | 1
- XOR | 10 | 11
- ```
- Questions:
- - Interesting enough? Is a vanilla factorial better?
- - Are the tags okay?
- - Needs more testcases?
- - Input rules okay?
- # Task
- I often need to find the factorial or a number of the sum of all numbers up to a number when cheating on math tests. To help me with this, your task is to write $F$, a generalized version of those functions:
- $$F(n) = 1 * 2 * ... * (n-1) * n$$
- Please note that the operator $ * $ does not necessarily represent multiplication here, but stands for a [commutative](https://en.wikipedia.org/wiki/Commutative_property), [associative](https://en.wikipedia.org/wiki/Associative_property) operator that will be an input to your program/function. This means that $a * b$ is the same as $b * a$, and $a * (b * c)$ is the same as $(a * b) * c$. Its inputs are positive integers, and its outputs are integers.
- # Rules
- - $n$ will be a positive integer.
- - $*$ is a binary function/operator that can be taken in any convenient format, including but not limited to:
- - A function object
- - A function pointer
- - An object with a method with a specific name (e.g. Java's [`BiFunction`](https://docs.oracle.com/javase/8/docs/api/java/util/function/BiFunction.html[]()))
- - A string that can be evaluated to get a function
- - $*$ is a blackbox function. That means that you will not be able to examine it to see how it works; all you can do is feed it two positive integers and get an integer back.
- - This is [code-golf], so shortest code in bytes wins!
- # Testcases
- ```
- f | n | F(f, n)
- Add | 1 | 1
- Add | 5 | 15
- Multiply | 1 | 1
- Multiply | 5 | 120
- XOR | 1 | 1
- XOR | 2 | 3
- XOR | 5 | 1
- XOR | 10 | 11
- ```
- Questions:
- - Interesting enough? Is a vanilla factorial better?
- - Are the tags okay?
- - Needs more testcases?
- - Input rules okay?
#2: Post edited
- # Task
- I often need to find the factorial of a number of the sum of all numbers up to a number when cheating on math tests. To help me with this, your task is to write $F$, a generalized version of those functions:
- $$F(n) = 1 * 2 * ... * (n-1) * n$$
Please note that the operator $*$ does not necessarily represent multiplication here, but stands for a commutative operator that will be an input to your program/function.- # Rules
- - $n$ will be a positive integer.
- - $*$ is a binary function/operator that can be taken in any convenient format, including but not limited to:
- - A function object
- - A function pointer
- An object with a method with a specific name (e.g. `apply`)- - A string that can be evaluated to get a function
- - This is [code-golf], so shortest code in bytes wins!
- # Testcases
- ```
- f | n | F(f, n)
- Add | 1 | 1
- Add | 5 | 15
- Multiply | 1 | 1
- Multiply | 5 | 120
- XOR | 1 | 1
- XOR | 2 | 3
- XOR | 5 | 1
- XOR | 10 | 11
- ```
- Questions:
- - Interesting enough? Is a vanilla factorial better?
- - Are the tags okay?
- - Needs more testcases?
- - Input rules okay?
- # Task
- I often need to find the factorial of a number of the sum of all numbers up to a number when cheating on math tests. To help me with this, your task is to write $F$, a generalized version of those functions:
- $$F(n) = 1 * 2 * ... * (n-1) * n$$
- Please note that the operator $ * $ does not necessarily represent multiplication here, but stands for a [commutative](https://en.wikipedia.org/wiki/Commutative_property), [associative](https://en.wikipedia.org/wiki/Associative_property) operator that will be an input to your program/function. This means that $a * b$ is the same as $b * a$, and $a * (b * c)$ is the same as $(a * b) * c$. Its inputs are positive integers, and its outputs are integers.
- # Rules
- - $n$ will be a positive integer.
- - $*$ is a binary function/operator that can be taken in any convenient format, including but not limited to:
- - A function object
- - A function pointer
- - An object with a method with a specific name (e.g. Java's [`BiFunction`](https://docs.oracle.com/javase/8/docs/api/java/util/function/BiFunction.html[]()))
- - A string that can be evaluated to get a function
- - $*$ is a blackbox function. That means that you will not be able to examine it to see how it works; all you can do is feed it two positive integers and get an integer back.
- - This is [code-golf], so shortest code in bytes wins!
- # Testcases
- ```
- f | n | F(f, n)
- Add | 1 | 1
- Add | 5 | 15
- Multiply | 1 | 1
- Multiply | 5 | 120
- XOR | 1 | 1
- XOR | 2 | 3
- XOR | 5 | 1
- XOR | 10 | 11
- ```
- Questions:
- - Interesting enough? Is a vanilla factorial better?
- - Are the tags okay?
- - Needs more testcases?
- - Input rules okay?
#1: Initial revision
Reduce over the range [1..n]
# Task I often need to find the factorial of a number of the sum of all numbers up to a number when cheating on math tests. To help me with this, your task is to write $F$, a generalized version of those functions: $$F(n) = 1 * 2 * ... * (n-1) * n$$ Please note that the operator $*$ does not necessarily represent multiplication here, but stands for a commutative operator that will be an input to your program/function. # Rules - $n$ will be a positive integer. - $*$ is a binary function/operator that can be taken in any convenient format, including but not limited to: - A function object - A function pointer - An object with a method with a specific name (e.g. `apply`) - A string that can be evaluated to get a function - This is [code-golf], so shortest code in bytes wins! # Testcases ``` f | n | F(f, n) Add | 1 | 1 Add | 5 | 15 Multiply | 1 | 1 Multiply | 5 | 120 XOR | 1 | 1 XOR | 2 | 3 XOR | 5 | 1 XOR | 10 | 11 ``` Questions: - Interesting enough? Is a vanilla factorial better? - Are the tags okay? - Needs more testcases? - Input rules okay?