Consider a sample space S consisting of all perfect squares starting from 1, 4, 9 and so on. You are given a number N, you have to output the number of integers less than N in the sample space S. code example
Example: all perfect squares up to n
def perfect_squares(minimum, maximum) :
# get first number
number = ceil(sqrt(minimum));
# get fisrt number's square
n2 = number * number;
# get next
number = (number * 2) + 1;
while ((n2 >= minimum and n2 <= maximum)) :
# print perfect square
print(n2, end= " ");
# find next perfect square
n2 = n2 + number;
# next odd number to be added
number += 2;