7
You will receive an integer less than 2000000000 and bigger than -2000000000 and you have to test what type(s) of number this is out of:
Factorial
Square
Cube
Prime
Composite
Triangular
Positive
Negative
Here is a definition of all the different types of numbers:
Factorial - A number That is equal to the product of all positive integers less than the a certain positive integer - 5×4×3×2×1 = 120
Square - A number that is the product of two identical integers - 5×5 = 25
Cube - A number that is the product of three identical integers - −5×−5×−5 = -125
Prime - A number that has only two divisors (1 and 0 are not) - 3
Composite - A number that has more than two divisors (also not 1 or 0) - 4
Triangular - A number that is equal the sum of all positive integers less than the a certain positive integer - 5+4+3+2+1 = 15
Positive - A number larger than 0 (not 0) - 7
Negative - A number less than 0 (not 0) - −7
Test Cases
-8 = ["Cube","Negative"]
-2 = ["Negative"]
-1 = ["Cube","Negative"]
0 = ["Cube", "Square", "Triangular"]
1 = ["Cube","Factorial","Positive","Square","Triangular"]
2 = ["Factorial","Positive","Prime"]
3 = ["Positive","Prime","Triangular"]
4 = ["Composite","Positive","Square"]
5 = ["Positive","Prime"]
6 = ["Composite","Factorial","Positive","Triangular"]
7 = ["Positive","Prime"]
8 = ["Composite","Cube","Positive"]
9 = ["Composite","Positive","Square"]
10 = ["Composite","Positive","Triangular"]
11 = ["Positive","Prime"]
12 = ["Composite","Positive"]
Note: The Order of the Result Does Not Matter and it can be expressed with words (Does Not Have To Be A List)
Remember, this is a code golf so the smallest answer in bytes is what I'm looking for
6Welcome to PPCG. Nice first challenge. You may want harmonise the casing and/or explicitly state that any casing is acceptable. Does the result have to be a list of strings or is any indication using those words OK? Could we substitute "codes" or bit or synonyms, etc.? – Adám – 2019-02-26T11:38:20.267
2Some more test cases would be nice too. – Adám – 2019-02-26T11:53:50.663
8Is -1 a triangular number? Is -4 a composite number? Please define your types to make the challenge self contained and add some examples. – flawr – 2019-02-26T12:34:34.773
1I really like this challenge idea, it would be nice if you could specify this a bit better. – Rɪᴋᴇʀ – 2019-02-26T15:24:38.050
I've taken the freedom to fix your definitions. Feel free to correct me if I'm wrong. – Adám – 2019-02-26T21:41:53.447
1You should still clarify whether casing is important (as yours is inconsistent) and whether answering by other means than with English words is acceptable. – Adám – 2019-02-26T21:43:19.257
3Do we actually have to be able to handle ±2×10⁹ or is it enough that the algorithm in principle works. Some solutions may want to calculate impractically large factorials or have practical issues with finding primality of large numbers. You may want to allow limiting to what's representable. – Adám – 2019-02-26T22:05:26.563
1The test cases leave out the fact that they are posivite – ASCII-only – 2019-02-27T01:51:25.090
@ASCII-only Fixed. – Adám – 2019-02-27T05:55:45.333
4Is 0 not a square and cube? – Neil A. – 2019-02-27T06:07:33.647
10 is also a triangular number, right? – Embodiment of Ignorance – 2019-02-28T06:22:58.657
It says that the result can be expressed with words, but not that it has to. Should this be interpreted as allowing alternate formats for results, including integer instead of string, etc? – gastropner – 2019-03-01T03:38:19.070
Zero is a square, a cube, and a triangular number. As you haven't as of yet replied to the relevant questions of the commenters above regarding whether a
0
input is a special case (test cases on their own aren't enough to specify the challenge), or edited this challenge to clarify them, I've voted to close it as unclear. – Erik the Outgolfer – 2019-03-02T14:16:03.820@EriktheOutgolfer 0 x 0 = 0, therefore it is square, 0 is a triangular number, 0 is a cube. 0 is not positive or negative – SimpleBinary – 2019-03-02T23:46:12.567
A number that has only two divisors (1 and 0 are not) - 3
. But 3 has only 1 divisor (which is 3). – tsh – 2019-03-04T03:39:43.543