Answers for "all perfect squares up to n"

1

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;
Posted by: Guest on July-24-2020

Python Answers by Framework

Browse Popular Code Answers by Language