Questions tagged [perfect-square]

Perfect square is an element of algebraic structure which is equal to the square (algebra) of another element.

87 questions
-1
votes
6 answers

Counting and generating perfect squares

I need some advice on how to write a Python program where it gives you a list of the first n perfect squares in list format. The output should look like this: How many squares?: 5 [1, 4, 9, 16, 25] This is what I have so far: n =…
captain_credible
-1
votes
2 answers

Use the Java Math square root method to calculate square roots from 1 to 1,000. Then output the whole numbers only

Use the Java Math square root method to calculate square roots from 1 to 1,000. The output the whole numbers only.Do not start by calculating squares and then printing out that number's square root. Calculate all square roots and determine if…
-1
votes
1 answer

Random numbers with squares in a 2d display

Can someone tell me why my second column is not the square of the fist? Here is what I have: const int NUM_ROWS = 10; const int NUM_COLS = 2; int[,] randint = new int [NUM_ROWS,NUM_COLS]; Random randNum = new Random(); for (int row = 0; row <…
KBS
  • 13
  • 1
  • 2
-2
votes
1 answer

What is the difference between these algorithms for checking for perfect square?

I was solving a problem where I had to determine whether the given number is a Fibonacci number or not. It involves a step where we have to check if 5*n*n-4 or 5*n*n+4 (n is given number and is always greater than 0) is a perfect square or not. If…
Ketan Sahu
  • 127
  • 1
  • 11
-2
votes
3 answers

How do I find the closest perfect square less than the input, or the perfect square can be the input

I want to make a program that gets a number input and finds the closest perfect square to determine the square length. Thus, the closest perfect square has to be less than the input. For example, if the input is 8, the largest side length of the…
user10086072
-2
votes
1 answer

Finding next perfect square

this code was supposed to find if given input is perfect square and to return next perfect square eg n=121-->144 but I don't know why it is not working To find next perfect square from math import sqrt,pow def perfect_sqr( n ): if…
nihal k
  • 23
  • 1
  • 5
-2
votes
2 answers

C++ No instance of overloaded function "sqrt" matches the argument list - Trying to find if a struct type array of numbers are perfect squares

I have a homework to do in C++, I'm trying to find if numbers from an array are perfect Square. Also, that array is dinamically allocated. Here is my code: myVector perfectSquare(myVector *vect) { myVector rez; rez.length = 0; for (int…
-2
votes
1 answer

Write a program in Visual Foxpro to check a number for perfect square

Ask the user to input a number. Check whether the entered number is a perfect square. I tried. enter image description here
-2
votes
2 answers

squaring a number in c++

Okay so I am going through bjarn stroustrups book on c++ and one of his exercises asks me to calculate the square of a number without using the multiplication operator. so the boiler plate code that I started off with is a function called square of…
user1995779
  • 5
  • 1
  • 1
-2
votes
5 answers

C++ How to change the output on a new array

So I wrote a program that is supposed select the perfect squares from an array and put it into another array. Example: (2,4,13,5,25,66) and the second array(the result) should look like this (4,25) My result looks like this (0,4,0,0,25,0) ...so its…
cUser26
  • 77
  • 1
  • 5
-3
votes
1 answer

Perfect Squares - Can someone explain following math?

Problem Statement: Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n. Example 1: Input: n = 12 Output: 3 Explanation: 12 = 4 + 4 + 4. Example 2: Input: n = 13 Output:…
User1990
  • 161
  • 11
-3
votes
1 answer

Check n numbers if they are perfect squares and how to calculate their sum?

the problem I have to solve is checking n numbers introduced by the user if they are perfect squares and then I have to calculate the sum of these perfect squares. I understand how to do these, but my code simply doesn't work at the part which…
1 2 3 4 5
6