perfect-square Questions

26

Solved

How could I check if a number is a perfect square? Speed is of no concern, for now, just working. See also: Integer square root in python.
Bobbiebobbin asked 22/3, 2010 at 0:48

7

Solved

I created a function that will test to see if a given parameter is a square number. Read about square numbers here: https://en.wikipedia.org/?title=Square_number If the number is a square number...
Elasticize asked 18/6, 2015 at 15:5

4

I would like to square every value in data, and I am thinking about using a for loop like this: data = rnorm(100, mean=0, sd=1) Newdata = {L = NULL; for (i in data) {i = i*i} L = i return (L)}
Garbanzo asked 24/1, 2014 at 0:16

1

Solved

How could I write an if-then statement that checks if an inputted integer is a perfect square or not (i.e. if I took the square root, it would be an integer as well: 4, 9, 16, 25, 36, etc.) i...
Unreasonable asked 3/12, 2015 at 2:5

2

Solved

This question is a follow-up on the post here: Fastest way to determine if an integer's square root is an integer, What's a good algorithm to determine if an input is a perfect square?. On...
Lamia asked 24/2, 2014 at 19:41

1

Solved

Part of my code is as follows: class Array def square! self.map {|num| num ** 2} self end end When I call: [1,2,3].square! I expect to get [1,4,9], but instead I get [1,2,3]. Why is this ...
Jacquie asked 23/5, 2013 at 20:33

4

Solved

I've just started learning Python and have started doing some problems just to help buid my skills however I am pretty stuck on this question. Make a list containing all positive integers up to 1...
Delmerdelmor asked 4/11, 2012 at 2:55

1

Solved

This is a code to check if a number is perfect square or not. Why does it work ? static bool IsSquare(int n) { int i = 1; for (; ; ) { if (n < 0) return false; if (n == 0) return true; ...
Remington asked 12/10, 2012 at 15:43

12

Can I rely on sqrt((float)a)*sqrt((float)a)==a or (int)sqrt((float)a)*(int)sqrt((float)a)==a to check whether a number is a perfect square? Why or why not? int a is the number to be judged....
Stewardson asked 9/9, 2009 at 9:42

3

Solved

Possible Duplicate: Fastest way to determine if an integer's square root is an integer What's a way to see if a number is a perfect square? bool IsPerfectSquare(long input) { /...
Alecalecia asked 5/12, 2008 at 13:35

37

Solved

I'm looking for the fastest way to determine if a long value is a perfect square (i.e. its square root is another integer): I've done it the easy way, by using the built-in Math.sqrt() function,...
Brunildabruning asked 17/11, 2008 at 13:43
1

© 2022 - 2024 — McMap. All rights reserved.