Smart Tech

Sunday, March 6, 2016

Count the Squares between any two numbers

import math

def get_squares(n1, n2): #Given n1, n2 are the numbers both inclusive

       print int(math.floor(math.sqrt(n2)) - math.ceil(math.sqrt(n1))) + 1
Posted by Sree Sindhu Sruthi at 4:00 PM
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: ceil, floor, math, Python, Squares

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Blog Archive

  • ►  2021 (6)
    • ►  September (1)
    • ►  August (1)
    • ►  July (4)
  • ►  2020 (1)
    • ►  May (1)
  • ►  2019 (2)
    • ►  March (2)
  • ►  2018 (1)
    • ►  February (1)
  • ►  2017 (3)
    • ►  May (2)
    • ►  January (1)
  • ▼  2016 (19)
    • ►  November (4)
    • ►  October (1)
    • ►  September (3)
    • ►  August (2)
    • ►  June (1)
    • ▼  March (2)
      • Project Euler - Problem 2 - Sum of even Fibonaaci ...
      • Count the Squares between any two numbers
    • ►  February (4)
    • ►  January (2)
  • ►  2015 (19)
    • ►  November (2)
    • ►  June (12)
    • ►  May (1)
    • ►  March (1)
    • ►  February (1)
    • ►  January (2)
  • ►  2014 (2)
    • ►  October (2)
  • ►  2013 (4)
    • ►  August (1)
    • ►  April (1)
    • ►  March (2)

About Me

Sree Sindhu Sruthi
View my complete profile
Simple theme. Theme images by luoman. Powered by Blogger.