Finding the Greatest Integer Square Root of an Integer

Click For Summary
The discussion centers on designing an algorithm to find the greatest integer less than or equal to the square root of a positive integer input, i. Participants clarify that a natural number refers to positive integers, providing examples such as sqrt(1) = 1 and sqrt(57) = 7. There is a request for guidance on how to express this in pseudo code for Pascal, with questions about whether to use sqrt(i) directly or if alternative methods are needed. The conversation emphasizes understanding the algorithm's requirements and proper coding syntax. Overall, the focus is on implementing a solution for calculating integer square roots efficiently.
teng125
Messages
416
Reaction score
0
Consider the square root operation. Suppose an integer numbers i > 0 as input variable.
Design an algorithm which calculates the greatest natural number less than or equal to
the square root of the input variable i.


can smby pls explain to me what does this ques mean??if possible explain using some example

thanx
 
Physics news on Phys.org
A natural number just means a positive integer, like 1, 2, 3, 4, 5.

Here are some examples of what your algorithm should do:
sqrt(1) = 1
sqrt(2) = 1
sqrt(3) = 1
sqrt(4) = 2
sqrt(5) = 2
sqrt(57) = 7
sqrt(170) = 13
 
what can i write for sqrt(i) in the pseudo code for pascal??

is it just sqrt(i) or any others??
 

Similar threads

  • · Replies 23 ·
Replies
23
Views
2K
  • · Replies 19 ·
Replies
19
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 22 ·
Replies
22
Views
884
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 30 ·
2
Replies
30
Views
6K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
1K