It's Hip to be Square

44

6

Challenge

So, um, it seems that, while we have plenty of challenges that work with square numbers or numbers of other shapes, we don't have one that simply asks:

Given an integer n (where n>=0) as input return a truthy value if n is a perfect square or a falsey value if not.


Rules

  • You may take input by any reasonable, convenient means as long as it's permitted by standard I/O rules.
  • You need not handle inputs greater than what your chosen language can natively handle nor which would lead to floating point inaccuracies.
  • Output should be one of two consistent truthy/falsey values (e.g., true or false, 1 or 0) - truthy if the input is a perfect square, falsey if it's not.
  • This is so lowest byte count wins.

Test Cases

Input:  0
Output: true

Input:  1
Output: true

Input:  64
Output: true

Input:  88
Output: false

Input:  2147483647
Output: false

Shaggy

Posted 2017-06-08T11:20:23.180

Reputation: 24 623

@Neil I realized my mistake. I retract that suggestion, and instead offer 18014398509481982 (2**54-2), which is representable with a double, and causes answers that use sqrt to fail. – Mego – 2017-06-08T12:24:56.033

@Mego I'm probably wrong or just misunderstanding what you're saying, but I'm sure 2**54-2 is still larger than a double can safely handle, at least in JavaScript 18014398509481982 > 9007199254740991 – Tom – 2017-06-08T12:32:02.703

@Mego I think the limiting value is 9007199515875288. It's not the square of 94906267, because that's not representable in a double, but if you take its square root, then you get that integer as the result. – Neil – 2017-06-08T12:33:29.257

@Tom Type 2**54-2 into a JS console, and compare what you get with 18014398509481982 (the exact value). JS outputs the exact value, therefore 2**54-2 is representable with a double. If that still doesn't convince you, take the binary data 0100001101001111111111111111111111111111111111111111111111111111, interpret it as a IEEE-754 double-precision float, and see what value you get. – Mego – 2017-06-08T12:41:02.743

Extremely relevant SO post. – Stewie Griffin – 2017-06-08T12:42:22.773

@Mego Numbers larger than 2^53 can be stored accurately as IEEE-754 double precision floats, "...but we all know they are tiny islands of exactitude in an ocean of near misses" – Stewie Griffin – 2017-06-08T12:48:48.780

@StewieGriffin Exactly. 2**54-2 is the smallest integer I found that is representable with a double, but is large enough that (n**.5)**2 != n due to inaccuracies in the calculations. – Mego – 2017-06-08T12:51:35.983

In my opinion, it's over-complicating things if we should start including numbers that high. If it's impossible to count to a number then it should be acceptable that we can't take the square root or do any other mathematical operation on it.

– Stewie Griffin – 2017-06-08T13:07:58.337

3Sorry, guys, stepped away for lunch and ... well, that escalated! And there I thought this would be a nice, simple challenge! Would adding a rule that you need not handle inputs that lead to floating point inaccuracies in your chosen language cover it? – Shaggy – 2017-06-08T13:17:14.097

@StewieGriffin That's not the current consensus. – Mego – 2017-06-08T13:27:44.180

Answers

27

Neim, 2 bytes

q

Explanation:

q      Push an infinite list of squares
      Is the input in that list?

When I say 'infinite' I mean up until we hit the maximum value of longs (2^63-1). However, Neim is (slowly) transitioning to theoretically infinitely large BigIntegers.

Try it!

Okx

Posted 2017-06-08T11:20:23.180

Reputation: 15 025

Comments are not for extended discussion; this conversation has been moved to chat.

– Dennis – 2017-06-10T15:24:43.947

Interesting. So, does this pre-buffer the list or is it a generator / iterator that continues checking for the existence of input until it terminates? – Patrick Roberts – 2017-06-10T16:46:08.067

@PatrickRoberts Can we talk in chat? – Okx – 2017-06-10T16:51:14.857

Sure, just ping me on The Nineteenth Byte. I'm in there occasionally.

– Patrick Roberts – 2017-06-11T04:59:41.020

Well, this is ... REALLY FUNCTIONAL – Chromium – 2018-06-15T09:03:25.527

10

Jelly, 2 bytes

Ʋ

Try it online!

Erik the Outgolfer

Posted 2017-06-08T11:20:23.180

Reputation: 38 134

1Also works with Ohm. – Nick Clifford – 2017-06-08T12:42:04.480

8

C#, 27 bytes

n=>System.Math.Sqrt(n)%1==0

A more correct/accurate way to do this would be:

n=>System.Math.Sqrt(n)%1<=double.Epsilon*100

TheLethalCoder

Posted 2017-06-08T11:20:23.180

Reputation: 6 930

double.Epsilon is useless for this type of check. tl;dr: When comparing numbers >2, Double.Epsilon is basically the same as zero. Multiplying by 100 will only delay that a bit. – Robert Fraser – 2017-06-08T14:17:04.490

@RobertFraser I only went by the linked SO post and didn't read to much into it. Either way it isn't useless just not to useful at higher numbers. – TheLethalCoder – 2017-06-08T14:21:12.563

...<int>==0 is ...!<int> I think – Stan Strum – 2018-01-13T20:39:29.913

@StanStrum Not in C# – TheLethalCoder – 2018-01-13T21:31:36.730

8

TI-Basic, 4 bytes

not(fPart(√(Ans

Simply checks if the square root is an integer by looking for a nonzero fractional/decimal part.

Timtech

Posted 2017-06-08T11:20:23.180

Reputation: 12 038

Can you add a TIO (or equivalent)? – Shaggy – 2017-06-08T13:23:22.493

@Shaggy I don't think there are any. TI-Basic is proprietary and will only run on TI's calculators and in emulators running the ROM from a calculator, so you cannot legally use TI-Basic if you don't own a calculator. – Adám – 2017-06-08T13:56:21.263

1@Shaggy If you have any ROMs you can use an emulator (my preference is jstified) to try this out online. – Timtech – 2017-06-08T15:18:03.520

7

JavaScript (ES6), 13 bytes

n=>!(n**.5%1)

Returns true if the square root of n is a whole number.

Snippet:

f=
n=>!(n**.5%1)

console.log(f(0));
console.log(f(1));
console.log(f(2));
console.log(f(4));
console.log(f(8));
console.log(f(16));
console.log(f(88));
console.log(f(2147483647));

Rick Hitchcock

Posted 2017-06-08T11:20:23.180

Reputation: 2 461

7

dc, 9

0?dvd*-^p

Outputs 1 for truthy and 0 for falsey.

Try it online.

0            # Push zero.  Stack: [ 0 ]
 ?           # Push input.  Stack: [ n, 0 ]
  dv         # duplicate and take integer square root.  Stack: [ ⌊√n⌋, n, 0 ]
    d        # duplicate.  Stack: [ ⌊√n⌋, ⌊√n⌋, n, 0 ]
     *       # multiply.  Stack: [ ⌊√n⌋², n, 0 ]
      -      # take difference. Stack: [ n-⌊√n⌋², 0 ]
       ^     # 0 to power of the result.  Stack: [ 0^(n-⌊√n⌋²) ]
        p    # print.

Note dc's ^ exponentiation command gives 00=1 and 0n=0, where n>0.

Digital Trauma

Posted 2017-06-08T11:20:23.180

Reputation: 64 644

Beautiful! +1 for using dc in such ingenious fashion. – Wildcard – 2017-06-10T00:26:35.397

6

Retina, 18 bytes

.+
$*
(^1?|11\1)+$

Try it online! Shamelessly adapted from @MartinEnder's answer to Is this number triangular? but with the base conversion included at a cost of 6 bytes.

Note that Is this number triangular? wasn't for some inexplicable reason required to support zero as a triangular number, so part of the adaption was to add a ? to make the leading 1 optional, allowing the group to match the empty string, and therefore a zero input. However, having now matched the empty string, the + operator stops repeating, to avoid the infinite loop that would happen if it kept greedily matching the empty string (after all, ^1? would certainly keep matching). This means that it doesn't even try to match the other alternative in the group, thus avoiding the match of 2, 6, 12 etc. As @MartinEnder points out, a simpler way to avoid that while still matching the empty string is to anchor the match at the start while making the group optional for the same byte count: ^(^1|11\1)*$.

Neil

Posted 2017-06-08T11:20:23.180

Reputation: 95 035

Looking forward to your explanation why this doesn't match 2, 6 or other numbers of the form n^2-n. ;) (A way to avoid that explanation for the same byte count would be ^(^1|11\1)*$.) – Martin Ender – 2017-06-08T12:54:41.797

@MartinEnder Same reason that you couldn't use (^|1\1)+$, I think? – Neil – 2017-06-08T13:12:36.577

Yeah that's right. Just thought it would probably be good to mention because most people probably haven't read my comment on the triangular answer (and in this case it's actually relevant to why the solution is correct, as opposed to just why it can't be golfed further). – Martin Ender – 2017-06-08T13:14:44.737

For the record, the + would also stop looping if there was no longer an empty alternative, e.g. in the case of ((?(1)11\1|1?))+. Once there was an empty iteration, it won't try any further ones, regardless of whether they may or may not be empty. – Martin Ender – 2017-06-08T13:33:27.553

@MartinEnder Indeed, I meant "having now matched" instead of "having immediately matched". Fixed. – Neil – 2017-06-08T14:36:22.233

6

MATL, 5 4 bytes

Thanks to Luis for reducing my one byte longer code by two bytes, making it the shortest one.

t:Um

Try it online

Explanation:

         % Implicit input
t        % Duplicate it
 :       % Range from 1 to input value
  U      % Square the range, to get 1 4 9 ... 
   m     % ismember, Checks if the input is a member of the range of perfect squares

Old answer:

X^1\~

Try it online!

        % Implicit input
X^      % Square root of input
  1\    % Modulus 1. All perfect squares will have 0, the rest will have decimal value
     ~  % Negate, so the 0 becomes 1, and the decimal values become 0

Stewie Griffin

Posted 2017-06-08T11:20:23.180

Reputation: 43 471

@Mego I disagree. MATL can't even do mod(2**127-, 1000). Unless the four last digits are 0....

– Stewie Griffin – 2017-06-08T12:02:16.903

You can also use t:Um. That works for inputs up to 2^53, due to floating point limited precision

– Luis Mendo – 2017-06-08T12:30:24.197

I see now that this is similar to your edit, only a little shorter :-) – Luis Mendo – 2017-06-08T12:31:36.903

Well hidden square command! U: str2num / string to array / square. I knew there had to be a square function, but I couldn't find it... – Stewie Griffin – 2017-06-08T12:32:01.773

Heh. It was a late addition, so I overloaded a bit :-) – Luis Mendo – 2017-06-08T12:33:17.153

Um... your first sentence confuses me – caird coinheringaahing – 2017-06-08T14:55:31.787

1@cairdcoinheringaahing that was partially on purpose. I had two solutions, one was 5 bytes, the other one 6 bytes. Luis golfed off two bytes from the one with 6. So I saved two bytes thanks to him, but I only saved a byte on the score... – Stewie Griffin – 2017-06-08T20:49:50.560

6

C (gcc), 30 bytes

f(n){n=sqrt(n)==(int)sqrt(n);}

Try it online!

C, 34 bytes

f(n){return(int)sqrt(n)==sqrt(n);}

Try it online!

C, 33 bytes

#define f(n)(int)sqrt(n)==sqrt(n)

Try it online!

Steadybox

Posted 2017-06-08T11:20:23.180

Reputation: 15 798

6

Python 3, 40 38 bytes

Thanks to squid for saving 2 bytes!

lambda n:n in(i*i for i in range(n+1))

Try it online!

Too slow to return an answer for 2147483647 in a reasonable amount of time. (But written using a generator to save memory, since it doesn't cost any bytes.)

Works in Python 2 also, though an OverflowError is a possibility due to range if you try it with huge inputs. (A MemoryError would also be likely in Python 2, also due to range.)

mathmandan

Posted 2017-06-08T11:20:23.180

Reputation: 943

5

05AB1E, 4 bytes

Ln¹å

Try it online!

Erik the Outgolfer

Posted 2017-06-08T11:20:23.180

Reputation: 38 134

Doesn't work for large numbers, for example 4111817668062926054213257208 – Emigna – 2017-06-08T11:28:34.050

@Emigna Oh because it's considered a long? I thought that 05AB1E uses Python 3. – Erik the Outgolfer – 2017-06-08T11:29:50.300

Fails for large inputs (the given input is 2**127-1, a Mersenne prime). – Mego – 2017-06-08T11:30:11.140

It does use python 3. The problem is that square root gives rounding errors for large numbers. – Emigna – 2017-06-08T11:30:39.657

@Emigna Oh...I guess I'll have to figure out another way then, shouldn't be hard. – Erik the Outgolfer – 2017-06-08T11:31:04.247

@Emigna Fixed, at the cost of a byte :( – Erik the Outgolfer – 2017-06-08T11:32:50.540

Was thinking Lƶå, but nope. – Magic Octopus Urn – 2017-06-08T15:05:15.050

5

Perl 5, 14 bytes

13 bytes of code + -p flag.

$_=sqrt!~/\./

Try it online!

Computes the square root, and looks if it's an integer (more precisely, if it doesn't contain a dot (/\./).

Dada

Posted 2017-06-08T11:20:23.180

Reputation: 8 279

5

Japt, 3 bytes

¬v1

Try it online!

Seems to work fine for 2**54-2 in the Japt Interpreter but fails on TIO for some reason...

Tom

Posted 2017-06-08T11:20:23.180

Reputation: 3 078

Fails for large inputs (input is 2**127-1, a Mersenne prime). – Mego – 2017-06-08T11:35:02.733

@Mego, isn't the norm that solutions need not handle numbers larger than the language is capable of handling? – Shaggy – 2017-06-08T11:36:00.917

@Shaggy Japt is based on JavaScript, which uses double-precision floats. 2**127-1 is well within the range of a double. – Mego – 2017-06-08T11:36:50.873

2@Mego Isn't the max safe int for JavaScript 2**53-1? – Tom – 2017-06-08T11:37:21.197

2**53-1 is the smallest value for which 1 ulp is less than or equal to 1. That's irrelevant here. – Mego – 2017-06-08T11:38:09.627

@Mego Should work for everything now, will just take a very long time to run for large numbers – Tom – 2017-06-08T12:10:10.813

I think just ¬v1 works (0 for falsy, 1 for truthy)... – Luke – 2017-06-08T12:33:58.353

@Luke That's what I was originally going to have, but Mego brought up the issue with large numbers which may or may not be correct. – Tom – 2017-06-08T12:38:13.783

3@Mego But JavaScript's numbers only have 53 bits of precision, so JS cannot exactly represent the value 2**127-1 as a number. The closest it can get is 2**127. – ETHproductions – 2017-06-08T17:01:30.820

5

Python 3, 19 bytes

lambda n:n**.5%1==0

Try it online!

sagiksp

Posted 2017-06-08T11:20:23.180

Reputation: 1 249

Fails for large inputs, e.g. 4111817668062926054213257208. – L3viathan – 2017-06-08T11:41:48.453

Fixed in 25 bytes: lambda n:int(n**.5)**2==n – L3viathan – 2017-06-08T11:43:28.333

4@L3viathan That (along with any solution that involves sqrt) fails on values which are outside of the range of a double, like 2**4253-1. – Mego – 2017-06-08T12:30:33.837

@totallyhuman a float after %1 is definitely <1, so your proposal would return true for all inputs. Note that n**.5 is a float. – Leaky Nun – 2017-06-08T13:33:17.837

5

SageMath, 9 bytes

is_square

Try it online

The built-in function does exactly what it says on the tin. Since Sage uses symbolic computation, it's free of computational accuracy errors that plague IEEE-754 floats.

Mego

Posted 2017-06-08T11:20:23.180

Reputation: 32 998

5

Haskell, 26 24 bytes

f n=elem n$map(^2)[0..n]

Try it online!

Checks if n is in the list of all squares from 0 to n.

nimi

Posted 2017-06-08T11:20:23.180

Reputation: 34 639

1same byte count: f n=or[i*i==n|i<-[0..n]] :) – vroomfondel – 2017-06-08T18:10:39.083

5

Prolog (SWI), 27 bytes

+N:-between(0,N,I),N=:=I*I.

Try it online!

Explanation

Searches through all numbers greater or equal to 0 and less than or equal to N and tests whether that number squared is equal to N.

0 '

Posted 2017-06-08T11:20:23.180

Reputation: 3 439

1

@DLosc done!

– 0 ' – 2018-01-15T15:36:55.037

5

MathGolf, 1 byte

°

Try it online!

I don't think an explanation is needed. I saw the need for an "is perfect square" operator before I saw this challenge, as the language is designed to handle math related golf challenges. Returns 0 or 1, as MathGolf uses integers to represent booleans.

maxb

Posted 2017-06-08T11:20:23.180

Reputation: 5 754

4

Ruby, 25 bytes

Math.sqrt(gets.to_i)%1==0

There probably is a shorter way but that's all I found.

Try it online!

Gregory

Posted 2017-06-08T11:20:23.180

Reputation: 61

Welcome to PPCG :) Could you add a TIO (or equivalent) to this, please?

– Shaggy – 2017-06-09T08:18:18.153

Thanks for adding the TIO however, this doesn't seem to return any output. – Shaggy – 2017-06-09T15:37:26.720

My bad, i updated it. – Gregory – 2017-06-09T15:43:39.193

Nope, still not working. – Shaggy – 2017-07-03T16:10:28.703

4

PHP, 21 bytes

<?=(-1)**$argn**.5<2;

If the square root is not an integer number, (-1)**$argn**.5 is NAN.

user63956

Posted 2017-06-08T11:20:23.180

Reputation: 1 571

How do I run this? – Titus – 2017-06-09T08:40:47.563

@Titus With the -F flag and pipeline: echo 144 | php -F script.php. – user63956 – 2017-06-09T08:44:55.143

Ah I forgot that letter. Thanks. – Titus – 2017-06-09T08:47:00.940

3

Java 8, 20 bytes

n->Math.sqrt(n)%1==0

Input is an int.

Try it here.

Kevin Cruijssen

Posted 2017-06-08T11:20:23.180

Reputation: 67 575

Not debatable: the question explicitly says "Given an integer n (where n>=0)". The shortest answer is the best. Edit: won't +1 until the shortest answer isn't the first :p – Olivier Grégoire – 2017-06-08T13:03:59.747

@OlivierGrégoire Hmm, that's a good way to look at it. But you still wouldn't know whether it's an int, long, short. And with questions where they ask for an integer but the input format is flexible, I sometimes use a String input to save some bytes. Personally I think using n-> is fine, and you should just state what the type is, but apparently not everyone agrees with this. On the other hand, coming from a Java 7 answer history, going from int c(int n){return ...;} to (int n)->... makes more sense than n->... (even though I personally prefer the second since shorter of course). – Kevin Cruijssen – 2017-06-08T13:10:06.827

2

@OlivierGrégoire Ok, I've changed it. After reading the discussion in this answer, I came to the conclusion that stating the input is an integer in Java, is no difference than stating the input is a list of two Strings in CJam or a cell array of strings in MATL.

– Kevin Cruijssen – 2017-06-09T08:05:10.133

3

Mathematica, 13 bytes

AtomQ@Sqrt@#&

Try it online!

J42161217

Posted 2017-06-08T11:20:23.180

Reputation: 15 931

No built in? Odd.... – TheLethalCoder – 2017-06-08T12:17:13.570

@TheLethalCoder If there is a built-in, it's probably longer than this. – Mego – 2017-06-08T12:48:27.637

1You can use AtomQ instead of IntegerQ. – Martin Ender – 2017-06-08T13:16:42.157

Can you add a TIO (or equivalent)? – Shaggy – 2017-06-08T13:22:06.803

1of course shaggy... – J42161217 – 2017-06-08T13:44:58.327

1You can still use @*. – Martin Ender – 2017-06-08T14:03:21.593

can you give me an example of input for @*? – J42161217 – 2017-06-08T14:06:13.210

4AtomQ@*Sqrt is a synonym for AtomQ@Sqrt@#&. For example, AtomQ@*Sqrt@4 returns True and AtomQ@*Sqrt@5 returns False. (Because of precedence, AtomQ@*Sqrt[4] doesn't work right, returning AtomQ@*2.) – Greg Martin – 2017-06-08T18:39:14.800

3

APL (Dyalog), 8 bytes

0=1|*∘.5

Try it online!

0= [is] zero equal to

1| the modulus-1 (i.e. the fractional part) of

*∘.5 the argument raised to the power of a half

Adám

Posted 2017-06-08T11:20:23.180

Reputation: 37 779

3

CJam, 8 bytes

ri_mQ2#=

Try it online!

Explanation

Integer square root, square, compare with original number.

Luis Mendo

Posted 2017-06-08T11:20:23.180

Reputation: 87 464

I guess according to this, you don't need the first 2 bytes

– Chromium – 2018-06-15T09:05:44.183

And, alternatively, using the idea of this answer, you can do mq1%0=, which is also 6 bytes

– Chromium – 2018-06-15T09:11:08.110

@Chromium Thanks, but in that case I need {...} to make the code a function, so same byte count – Luis Mendo – 2018-06-15T09:21:37.413

Actually, I'm a bit confused whether to add curly braces or not. Cuz if you don't add them, it's actually a program, which is permitted. – Chromium – 2018-06-15T09:23:59.583

@Chromium A program needs to take its input, so ri is required in that case – Luis Mendo – 2018-06-15T09:27:31.547

3

Add++, 24 13 11 bytes

+?
S
%1
N
O

Try it online!

I removed the clunky function at the top and rewrote it into the body of the question to remove 11 bytes.

As the first section is already explained below, let's only find out how the new part works

S   Square root
%1  Modulo by 1. Produced 0 for integers and a decimal for floats
N   Logical NOT

Old version, 24 bytes

D,i,@,1@%!
+?
^.5
$i,x
O

Try it online!

The function at the top (D,i,@,1@%!) is the main part of the program, so let's go into more detail.

D,     Create a function...
  i,   ...called i...
  @,   ...that takes 1 argument (for this example, let's say 3.162 (root 10))
    1  push 1 to the stack; STACK = [1, 3.162]
    @  reverse the stack;   STACK = [3.162, 1]
    %  modulo the stack;    STACK = [0.162]
    !  logical NOT;         STACK = [False]

+?     Add the input to accumulator (x)
^.5    Square root (exponent by 0.5)
$i,x   Apply function i to x
O      Output the result

caird coinheringaahing

Posted 2017-06-08T11:20:23.180

Reputation: 13 702

3

AWK, 27+2 bytes

{x=int($0^0.5);$0=x*x==$1}1

Try it online!

Add +2 bytes for using the -M flag for arbitrary precision. I originally used string comparison because large number compared equal, even though they weren't, but the sqrt was also returning imprecise values. 2^127-2 should not be a perfect square.

Robert Benson

Posted 2017-06-08T11:20:23.180

Reputation: 1 339

3

T-SQL, 38 bytes

SELECT IIF(SQRT(a)LIKE'%.%',0,1)FROM t

Looks for a decimal point in the square root. IIF is specific to MS SQL, tested and works in MS SQL Server 2012.

Input is in column a of pre-existing table t, per our input rules.

BradC

Posted 2017-06-08T11:20:23.180

Reputation: 6 099

3

Ohm, 2 bytes

Ʋ

Uses CP-437 encoding.

Explanation

Implicit Input -> Perfect square built-in -> Implicit Output...

Roman Gräf

Posted 2017-06-08T11:20:23.180

Reputation: 2 915

3

Python 3, 28 27 25 bytes

  • Thanks to @mdahmoune for 1 byte: compare int of root squared with original
  • 2 bytes saved: lambda shortened
lambda x:int(x**.5)**2==x

Try it online!

officialaimm

Posted 2017-06-08T11:20:23.180

Reputation: 2 739

1what about f=lambda x:int(x.5)2==x 27bytes – mdahmoune – 2017-07-03T15:30:36.467

3

R, 15

scan()^.5%%1==0

^.5 is less bytes than sqrt(). %%1, the modulus, will result in 0 if answer is an interger. scan() takes user input.

http://www.tutorialspoint.com/execute_r_online.php?PID=0Bw_CjBb95KQMSm1qVktIOUdSSDg

Shayne03

Posted 2017-06-08T11:20:23.180

Reputation: 347

2

PHP, 26 bytes

<?=(0^$q=sqrt($argn))==$q;

Try it online!

Jörg Hülsermann

Posted 2017-06-08T11:20:23.180

Reputation: 13 026

2

Actually, 6 bytes

;ur♂²c

Try it online!

-2 bytes from Erik the Outgolfer

Explanation:

;ur♂²c
;ur       range(n+1) ([0, n])
   ♂²     square each element
     c    does the list contain the input?

This takes a while for large inputs - TIO will timeout.

Mego

Posted 2017-06-08T11:20:23.180

Reputation: 32 998

Can't you replace íub with c? – Erik the Outgolfer – 2017-06-09T15:09:16.913

@EriktheOutgolfer You're absolutely right I believe, and I have a lot of answers to update because I didn't think about that. – Mego – 2017-06-10T01:30:12.167

I actually tried to outgolf you, but then I thought the algorithm was way too similar to post, so I converted it to a golfing tip instead... – Erik the Outgolfer – 2017-06-10T10:09:36.003

2

C (gcc), 66 43 42 bytes

f(float n){return!(sqrt(n)-(int)sqrt(n));}

Try it online!

Thanks to TheLethalCoder for the tip!

@hvd Thanks for saving a byte!

Abel Tom

Posted 2017-06-08T11:20:23.180

Reputation: 1 150

Can you just do: bool f(float n){return !sqrt(n)-(int)sqrt(n)>0;} or similar? Been a while since I've used C. – TheLethalCoder – 2017-06-08T12:21:05.177

@TheLethalCoder yea absolutely man. :) i would have to incluede stdbool.h though, therefore int as return type would be shorter. – Abel Tom – 2017-06-08T12:26:38.697

There's no need for a space between return and !. – hvd – 2017-06-11T13:54:33.420

1Suggest f(n) instead of f(float n) and (n=sqrt(n)) instead of (int)sqrt(n). – ceilingcat – 2017-11-02T04:33:24.690

2

CJam, 12 bytes

{_),2f##)!!}

Try it online!

Erik the Outgolfer

Posted 2017-06-08T11:20:23.180

Reputation: 38 134

2

Python, 53 50 49 48 49 48 bytes

This should in theory work for an input of any size. Returns True if the given number is a square, False otherwise.

f=lambda n,x=0:x<=n if~-(x<=n!=x*x)else f(n,x+1)

Try it online!

Explanation:

f=                                                # assign a name so we can call it
  lambda n,x=0:                                   # counter variable x
               x<=n                               # counter bigger than input?
                    if~-(         )               # "negate" inner condition
                         x<=n                     # counter not bigger
                            n!=x*x                # and n not square of x
                                   else f(n,x+1)  # else recurse

The condition is just a de-Morgan'd if x>n or n==x**2, i.e. we return if the counter is bigger than the input, or we found a proof for squareness.

Saved 1 byte thanks to Gábor Fekete.

L3viathan

Posted 2017-06-08T11:20:23.180

Reputation: 3 151

Your outputs are the wrong way 'round ;) – Shaggy – 2017-06-08T13:21:44.983

Technically, my output is "one of two consistent truthy/falsey values". But if you deem this invalid, I can correct it at the cost of one byte. – L3viathan – 2017-06-08T13:27:31.133

I'll edit the question to clarify, I see now that my phrasing in the rules was open to "interpretation", although it was clearer in the intro. – Shaggy – 2017-06-08T13:30:39.260

@Shaggy Well, I knew that isn't what you intended. Anyways, I'll edit my answer to adjust. – L3viathan – 2017-06-08T13:31:34.370

Can you add a TIO as well? – Shaggy – 2017-06-08T13:34:24.903

1@Shaggy Yes, done. – L3viathan – 2017-06-08T13:38:55.800

1Use x*x instead of x**2, saves 1 byte :) – Gábor Fekete – 2017-06-08T14:29:27.007

2

APL, 5 bytes

⊢∊⍳×⍳

Explanation:

⊢           N
  ∊         in
    ⍳        numbers up to N
      ×     times
        ⍳    numbers up to N

Test:

      ((⊢∊⍳×⍳) ¨ X) ,[÷2] X←⍳25
1 0 0 1 0 0 0 0 1  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

marinus

Posted 2017-06-08T11:20:23.180

Reputation: 30 224

Can you add a TIO (or equivalent)? – Shaggy – 2017-06-08T13:22:53.227

doesn't work for 0, but you could do ⊢∊0,⍳×⍳ and it's still the shortest APL answer – ngn – 2018-06-15T11:07:46.167

2

JavaScript on NodeJS & Chrome, 51 bytes

// OLD: t=n=>{i=Number.isSafeInteger;return i(n)&&i(n**.5)}

i=Number.isSafeInteger;t=n=>i(n)&&i(n**.5) 
// TestCases:
let l=console.log;l(`t(1): ${t(1)}; t(64): ${t(64)}; t(88): ${t(88)};`)

Try it online!

BogdanBiv

Posted 2017-06-08T11:20:23.180

Reputation: 123

Welcome to PPCG. You don't need to include the t= in your byte count nor is input validation required for this challenge. – Shaggy – 2017-06-08T14:00:49.980

Also works for Firefox – WORNG ALL – 2017-07-03T14:57:53.963

@rickhitchcock does have a point - input validation should not be required! Quote: "You need not handle inputs greater than what your chosen language can natively handle nor which would lead to floating point inaccuracies." – BogdanBiv – 2017-07-10T13:27:37.553

2

MIPS, 112 bytes

main:li $v0,7
syscall
sqrt.d $f0,$f0
mfc1 $a0,$f0
li $v0,1
beqz $a0,t
li $a0,0
syscall
b e
t:li $a0,1
syscall
e:

Try it online!

Outputs 1 if the input is square, 0 if not.

Explanation

main:li $v0,7      #Start of program. Load service 7 (read input as float to $f0). 
                   #Input can be an integer, but MIPS will interpret it as a float.
syscall            #Execute.

sqrt.d  $f0,$f0    #Overwrite $f0 with its square root, stored as a double.
mfcl    $a0,$f0    #Move $f0 to $a0.
li      $v0,1      #Load service 1 (print int from $a0).
beqz    $a0,t      #Branch to label 't' if $a0 = 0. Otherwise continue.

#If input is non-square...
li      $a0,0      #Load 0 into $a0.
syscall            #Execute (print $a0).
b e                #Branch to label 'e'.

#If input is square...
t:li    $a0,1      #Start of label 't'. Load 1 into $a0.
syscall            #Execute (print $a0).

e:                 #Start of label 'e'. Used to avoid executing 't' when input isn't square.

A double in MIPS is 16 hexes. It shares its address with a float containing its low-order 8 hexes ($f0 in this case). The high-order hexes are stored in the next register ($f1), also as a float.

          float             double 
$f0     0000 0000     1111 1111 0000 0000
$f1     1111 1111

Taking the square root of a non-square number requires the entire double in order to be stored, meaning the high and low floats are populated. The square root of a square number only needs a few hexes from the double to be stored, and it is stored specifically in its high-order hexes. This means the low float is left at 0.

If the low float equals 0, the input is a square number.

Bsoned

Posted 2017-06-08T11:20:23.180

Reputation: 31

you have a bit of superfluous whitespace – ASCII-only – 2019-03-13T03:49:07.993

91? – ASCII-only – 2019-03-13T04:17:31.830

2

Whitespace, 95 bytes

[S S S N
_Push_0][S N
S _Duplicate_top][T N
T   T   _Read_STDIN_as_integer][N
S S N
_Create_Label_LOOP][S N
S _Duplicate_top][S N
S _Duplicate_top][T S S N
_Multiply_top_two][S S S N
_Push_0][T  T   T   _Retrieve_input][S N
T   _Swap_top_two][T    S S T   _Subtract][S N
S _Duplicate_top][N
T   S S N
_If_0_jump_to_Label_TRUE][N
T   T   T   N
_If_negative_jump_to_Label_FALSE][S S S T   N
_Push_1][T  S S S _Add][N
S N
N
_Jump_to_Label_LOOP][N
S S S N
_Create_Label_TRUE][S S S T N
_Push_1][T  N
S T _Print_as_integer][N
N
N
_Stop_program][N
S S T   N
_Create_Label_FALSE][S S S N
_Push_0][T  N
S T _Print_as_integer]

Letters S (space), T (tab), and N (new-line) added as highlighting only.
[..._some_action] added as explanation only.

Outputs 1/0 for truthy/falsey respectively. A few bytes could be saved if something like 00/0 for truthy/falsey is allowed instead.

Try it online (with raw spaces, tabs and new-lines only).

Explanation in pseudo-code:

Read STDIN as integer, and store it in the heap
Integer i = 0
Start LOOP:
  Integer temp = i*i - input from heap
  If(temp == 0):
    Call function TRUE
  If(temp < 0):
    Call function FALSE
  i = i + 1
  Go to next iteration of LOOP

function TRUE:
  Print 1 as integer
  Stop program
function FALSE:
  Print 0 as integer
  (implicitly stop the program with an error)

Here a port of this approach in Java:

int func(int input){
  for(int i=0; /*infinite loop*/; i++){
    int m = input - i*i;
    if(m==0) return 1;
    if(m<1) return 0;
  }
}

Try it online.

Kevin Cruijssen

Posted 2017-06-08T11:20:23.180

Reputation: 67 575

1

Pyth, 5 bytes

/^R2h

Try it here!

Erik the Outgolfer

Posted 2017-06-08T11:20:23.180

Reputation: 38 134

An alternative 5-byte solution that doesn't work for larger numbers (e.g. 2**127 - 1) would be sI@Q2, but I have to admit that I am quite fond of your right map answer. – notjagan – 2017-06-08T15:19:25.753

1

QBIC, 16 18 bytes

[:|~b/a=a|_Xq}?b=0

Added two bytes for 0-case

This runs through i = 1 ... n to see if n / i == i. Prints 1 if such an i is found, prints -1 for N=0 and 0 in all other cases. Both 1 and -1 are considered truthy in QBasic (-1 being the actual value for true, but IF (n) only is false on n=0).

steenbergh

Posted 2017-06-08T11:20:23.180

Reputation: 7 772

Can you add a TIO (or equivalent)? – Shaggy – 2017-06-08T13:21:06.433

@Shaggy unfortunately not. My attempts to have QBasic / QBIC / DosBox run on a webpage have been unfruitful, to put it mildly... I've considered running it from CGI, but QBasic is just too powerful to do that, that's asking for exploits... I'm open to suggestions. – steenbergh – 2017-06-08T13:23:40.460

I just wanted to check if it returns true for 0. – Shaggy – 2017-06-08T13:25:28.477

@Shaggy it would print 0 for N=0. It never enters the FOR loop and jumps straight to the last statement. I'll fix that – steenbergh – 2017-06-08T13:28:52.633

1

C, 33 bytes

#define f(x)sqrt(x)==(int)sqrt(x)

Takes an integer x. Checks if the square root of x is the square root of x rounded to an integer.

Try it online!

MD XF

Posted 2017-06-08T11:20:23.180

Reputation: 11 605

1

Excel, 18 16 bytes

=MOD(A1^0.5,1)=0

Wernisch

Posted 2017-06-08T11:20:23.180

Reputation: 2 534

1

Python 3, 39 38 Bytes

lambda n:n in(i*i for i in range(n+1))

@mathmandan I had the same idea, and this implementation is 1 byte shorter. I wanted to comment on your post but do not yet have 50 reputation. I hope you see this!

This is just brute force, and I did not get it to complete 2147483647 in a reasonable amount of time.

Thanks @DJMcMayhem for suggesting i remove the space after in

Try it Online

jacoblaw

Posted 2017-06-08T11:20:23.180

Reputation: 264

Welcome to the site! Just FYI, you could remove a space after in – James – 2017-06-09T20:04:33.070

Could you add a TIO or equivalent, please?

– Shaggy – 2017-07-03T16:11:10.580

1

Pari/GP, 8 bytes

issquare

Try it online!

alephalpha

Posted 2017-06-08T11:20:23.180

Reputation: 23 988

1

Pyke, 3 bytes

,$P

Try it here!

,   -   sqrt(input)
 $  -  float(^)
  P - is_int(^)

This could be two bytes (and is in older versions) if Pyke didn't helpfully automatically cast the results of sqrt to an integer if it's a square number.

Blue

Posted 2017-06-08T11:20:23.180

Reputation: 26 661

1

Charcoal, 8 bytes

¬﹪XN·⁵¦¹

Try it online!

Explanation

¬           Not
 ﹪      ¦¹ Modulo 1
   X  ·⁵   To the power of .5
     N     Next input as number, 

ASCII-only

Posted 2017-06-08T11:20:23.180

Reputation: 4 687

1

05AB1E, 5 3 bytes

t.ï

Try it online!

Longer than @Erik's but just wanted to give it a shot.

Now shorter than Erik's but fails for large numbers...

Explanation

t            # square roots the input
 .ï          # checks if number on stack is an int
             # implicit output of result (0 or 1)

space junk

Posted 2017-06-08T11:20:23.180

Reputation: 305

1

Common Lisp, 30 bytes

(defun g(x)(=(mod(sqrt x)1)0))

Try it online!

or, with the same length,

(defun g(x)(integerp(sqrt x)))

Renzo

Posted 2017-06-08T11:20:23.180

Reputation: 2 260

1

><>, 22+3 = 25 bytes

01-\:*=n;
(?!\1+::*{:}

Try it online!

Input is expected on the stack at program start, so +3 bytes for the -v flag.

Sok

Posted 2017-06-08T11:20:23.180

Reputation: 5 592

1

tinylisp, 67 bytes

(load library
(d S(q((n)(contains?(map(q((x)(* x x)))(c 0(1to n)))n

Try it online!

Generates a list of numbers from 0 through n, maps a lambda function that squares each one, and checks if n is in the resulting list of squares. Wildly inefficient, of course.


Here's a 77-byte solution that doesn't use the library and runs an order of magnitude faster:

(d _(q((x n s)(i(e n s)1(i(l n s)0(_(a x 1)n(a s(a x(a x 1
(d S(q((n)(_ 0 n 0

Try it online!

This one uses a helper function _ which tracks a counter x and its square s. At each level of recursion, we return success if s equals n and failure if s is greater than n; otherwise, if s is still less than n, we recurse, incrementing x and calculating the next s by the formula (x+1)^2 = x^2 + x + x + 1.

DLosc

Posted 2017-06-08T11:20:23.180

Reputation: 21 213

1

Julia 0.6, 12 bytes

n->√n%1==0

Try it online!

Pretty straightforward, having the Unicode for square-root saves a few bytes.

sundar - Reinstate Monica

Posted 2017-06-08T11:20:23.180

Reputation: 5 296

1

Japt -¡E, 2 bytes

¬d

Run it online

Oliver

Posted 2017-06-08T11:20:23.180

Reputation: 7 160

1

PowerShell, 26 bytes

!([math]::Sqrt("$args")%1)

Try it online!

mazzy

Posted 2017-06-08T11:20:23.180

Reputation: 4 832

1

Python 3, 27 25 24 bytes

saved bytes by simplifying order of operation and comparing roots instead of squared value

lambda n:n**.5//1==n**.5

Try it online!

SmileAndNod

Posted 2017-06-08T11:20:23.180

Reputation: 119

Hello and welcome to PPCG. I think you should specify that you are using Python 3. Furthermore, is %1==0 not shorter and accomplishes the same? – Jonathan Frech – 2019-03-03T13:52:11.503

@JonathanFrech This works in 2 and 3. And yes, %1==0 is shorter and wins. Is there an easy way to filter past answers by language of implementation so I can quickly see what other users have already submitted? – SmileAndNod – 2019-03-03T14:11:34.030

1It only works in some newer Python 2 versions. – Jonathan Frech – 2019-03-03T14:16:23.807

@JonathanFrech Ah. I don't have access to old versions of python 2. Any site like TIO that tests all versions? – SmileAndNod – 2019-03-03T14:19:21.890

Explicit untrue division was introduced in Python 2.2; no, unfortunately I do not know of any online Python version history interpreter site.

– Jonathan Frech – 2019-03-03T14:54:47.713

1

SNOBOL4 (CSNOBOL4), 61 bytes

	N =INPUT
T	OUTPUT =EQ(X * X,N) 1
	X =LT(X,N) X + 1	:S(T)
END

Try it online!

Increment X until either X ^ 2 is equal to N in which case the program outputs 1 or until X > N in which case the program outputs nothing.

Giuseppe

Posted 2017-06-08T11:20:23.180

Reputation: 21 077

1

k4, 12 9 bytes

 x=_x:sqrt

with num(s) to be checked passed right-side, e.g.

 x=_x:sqrt 36 35 25
101b

get square root and check if the it is equal to the square root cast to int. if not a square number, the square root will have a decimal place and the cast will cut the decimal off

edit: -3 thanks to ngn :)


K (oK), 8 bytes

x=`i$x:%

Try it online!

Same logic but in oK, an implementation of k6 (no online k4 interpreter that i'm aware of). Test like:

 x=`i$x:% 16 24 81
1 0 1

scrawl

Posted 2017-06-08T11:20:23.180

Reputation: 1 079

Could you add a TIO (or equivalent)? From your explanation, it sounds like you may have posted this to the wrong challenge.

– Shaggy – 2019-08-27T09:01:49.590

@Shaggy, apologies... i did. deleting – scrawl – 2019-08-27T09:03:19.527

@Shaggy corrected – scrawl – 2019-08-27T09:17:09.940

Thanks. Could you add a link to somewhere we can test it, though? – Shaggy – 2019-08-27T10:00:22.270

@Shaggy i have added a solution in oK which can be tested at TIO! – scrawl – 2019-08-27T13:52:33.273

"i"$ -> _­­ – ngn – 2019-10-10T13:46:54.400

@ngn updated, thanks! – scrawl – 2019-10-11T11:11:31.420

1

brainfuck, 42 bytes

->>,[[-<<<+>>>]<<++[[-<]<+>>>]<<<[<]>>>]<.

Try it online!

Outputs the NUL byte for square numbers and SOH for non-squares. Uses the property that square numbers are the cumulative sum of odd numbers, i.e. 1, 1+3, 1+3+5 etc.

There might be a better way of arranging the cells so as to reduce the number of pointer movements and save bytes.

Jo King

Posted 2017-06-08T11:20:23.180

Reputation: 38 234

Just tested this quickly on my phone and it seems to be giving different outputs for inputs of 1 & 64. – Shaggy – 2019-08-27T16:12:34.330

@Shaggy On TIO it is using input as a character code, so 1 (49) will be square but 64 (54) won't be. @ and SOH both output the NUL byte for me. You can use an interpreter like copy.sh to test actual numbers more easily

– Jo King – 2019-08-27T21:11:42.403

You're not taking input as a number. Look at @Shaggy s comment on my answer. – Krzysztof Szewczyk – 2019-08-28T12:34:47.753

I'm using the interpreter from copy.sh which does allow input as a number. I could have sworn there was an answer under standard IO that allowed numerical input as byte code, but I can't find it. I guess I'll add it and see if it passes community consensus

– Jo King – 2019-08-28T12:42:15.770

Ah, here it is. I wonder why it isn't under standard IO

– Jo King – 2019-08-28T12:43:17.647

Ah-ha! I vaguely remembered seeing something about that on Meta, but I was looking for it in the standard I/O question. Looks like a strong enough consensus to me so I'll allow it, even if I don't necessarily agree with it. That goes for your solution, too, @KrzysztofSzewczyk. – Shaggy – 2019-08-28T17:17:04.177

1

Brain-Flak, 92 bytes

(({})){{}([(({}[({})({}())])[(())])](<>)){({}())<>}{}{((<{}>))<>{}}{}<>{}}{}({()(<{}>)}{}<>)

Try it online!

MegaTom

Posted 2017-06-08T11:20:23.180

Reputation: 3 787

0

J, 8 bytes

(=~<.)%:

Explanation:

  • %: square root
  • =~ is the argument equal to itself
  • <. floor of
  • =~<. a J hook, which modifies the right argument by applying <.
  • so, "is the floor of the square root equal to itself?"

Note: If we want to save the above to a variable as a verb, we must do, eg:

issq=.(=~<.)@%:

Jonah

Posted 2017-06-08T11:20:23.180

Reputation: 8 729

Could you add a TIO (or equivalent) to this, please?

– Shaggy – 2017-06-09T08:19:47.823

I tried it, but it's not producing any output. Not sure if the J interpreter is down or if I'm missing something, but if you paste the following test into jconsole: (=~<.)%: 1 4 9 16 ,: 2 3 7 21 it will return a table with a row of 1s on top of a row of 0s, as expected. I tried putting the same into the "Code" section of TIO and then hitting run, but I get no output. – Jonah – 2017-06-09T18:24:05.773

0

Python 2, 33 bytes

 g = lambda x: (x**.5).is_integer()

OlafM

Posted 2017-06-08T11:20:23.180

Reputation: 9

Welcome to PPCG! There seems to be a bit of unnecessary whitespace in your entry, such as after the colon, and also anonymous lambdas are valid submissions, meaning you can omit the g= from the start. Also I believe %1!=0 is shorter than .is_integer() – Skidsdev – 2017-06-15T07:57:53.347

@Mayube You probably meant ==0? – Martin Ender – 2017-06-15T08:04:42.823

@MartinEnder I did, yes – Skidsdev – 2017-06-15T08:48:30.787

0

Python 2, 25 bytes

lambda n:int(n**.5)**2==n

Try it online!

mdahmoune

Posted 2017-06-08T11:20:23.180

Reputation: 2 605

0

Ruby, 16 bytes

->n{n**0.5%1==0}

Trivial solution.

G B

Posted 2017-06-08T11:20:23.180

Reputation: 11 099

0

C++, 43 bytes

bool c(int n){int t=sqrt(n);return t*t==n;}

New version: https://repl.it/repls/CompatibleJumpyCoordinates

If your number is perfect square then it will return 1, otherwise it will return 0;

Old version: https://repl.it/repls/WateryTroubledProjects (not valid because it is the snippet only by @Jonathan Frech)

If your number is perfect square then it will be exited with status 1, otherwise it will not exist;

chau giang

Posted 2017-06-08T11:20:23.180

Reputation: 725

Note that in its current form, this answer would be regarded as a snippet, which is not allowed. Please fix your answer to be of a valid form, i.e. a full program or function. – Jonathan Frech – 2019-03-03T15:43:56.483

@JonathanFrech, thank you for your comment, can I add only the function like my answer above? – chau giang – 2019-03-03T16:17:37.707

Yes, in its current form your answer appears to be valid. – Jonathan Frech – 2019-03-03T18:31:07.243

0

BFASM, 204 bytes

The function is taking input in r2 and outputs its value into r1.

lbl 1
mov r3,1
lbl 2
mov r4,r3
mul r4,r3
le_ r4,r2
jz_ r4,3
mov r4,r2
mod r4,r3
jz_ r4,4
lbl 5
inc r3
jmp 2
lbl 4
mov r4,r2
div r4,r3
eq_ r4,r3
jz_ r4,5
mov r1,1
ret
lbl 3
clr r1
ret

Krzysztof Szewczyk

Posted 2017-06-08T11:20:23.180

Reputation: 3 819

I think you may have posted this to the wrong challenge. – Shaggy – 2019-08-27T09:48:02.607

@Shaggy why did I? – Krzysztof Szewczyk – 2019-08-27T09:48:48.247

The challenge is about determining whether a number is a perfect square or not, which neither of your solutions appears to do. – Shaggy – 2019-08-27T09:51:29.930

@Shaggy I'm streteching the I/O rules a bit, because it's inpractical as heck to read a number in Brainfuck, therefore I perform a single read. There are some integer based brainfuck interpreters so theoretically this solution is valid. – Krzysztof Szewczyk – 2019-08-27T09:52:06.690

Unless we have a consensus on this input format, I'm going to say it's not valid for this challenge as the spec explicitly states that you will be given an integer as input. – Shaggy – 2019-08-27T09:55:50.753

@Shaggy you are completely wrong, because this I/O rule allows assembly programs to take input from somewhere in memory, and straight below it, other consensus allows to put output somewhere in memory. In this case, the memory locations are r1 and r2.

– Krzysztof Szewczyk – 2019-08-27T10:01:40.300

Also, thanks for the clarification that I don't need to give the stub code. – Krzysztof Szewczyk – 2019-08-27T10:02:10.070

I was referring to you taking input as a character instead of an integer. – Shaggy – 2019-08-27T10:07:36.767

@Shaggy it's already fixed, because now I take input just by registers. – Krzysztof Szewczyk – 2019-08-27T10:08:12.393

@JoKing in that case, the challenge clearly stated about permitting the loophole. In this case, the author put emphasis on default I/O rules. – Krzysztof Szewczyk – 2019-08-27T10:09:20.540

0

Forth (gforth), 31 bytes

: f dup s>f fsqrt f>s dup * = ;

Try it online!

The input is a positive signed single-cell integer (0 <= n < 2^63 for 64-bit systems). To support full unsigned integer range, do 0 d>f instead of s>f.

Using floats turns out to be shorter than a loop.

How it works

: f ( n -- f )  \ Takes a positive signed int and gives whether it's a square or not
  dup           \ Duplicate n
  s>f fsqrt f>s \ Move to floating-point stack, take sqrt and move back (truncate)
  dup * =       \ Square the result and compare with n
;

gforth's comparison operators give -1 for true, 0 for false.

Bubbler

Posted 2017-06-08T11:20:23.180

Reputation: 16 616