Skip to content

Instantly share code, notes, and snippets.

@kishaningithub
Last active August 29, 2015 14:15
Show Gist options
  • Save kishaningithub/fc03058dcc88359006ca to your computer and use it in GitHub Desktop.
Save kishaningithub/fc03058dcc88359006ca to your computer and use it in GitHub Desktop.
Competitive programming maths
Is Fibonacci
- Either 5x^2+4 or 5x^2-4 must be a perfect square
No of perfect squares between a and b
- floor(sqrt(b)) - ceil(sqrt(a)) + 1
GCD (Euclid's algorithm) -
p>0 q>0. If q is 0 p is gcd. If not divide p by q
and take the remainder r. The gcd is the gcd(q,r).
gcd(p,q)
if(q=0)
return p
r = p % q
return gcd(q,r)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment