Shapes & spaces

Lattice points on an integer segment calculator

Count integer-grid points on a segment without enumerating all intervening coordinates.

Your numbers

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Count integer-grid points on a segment without enumerating all intervening coordinates.

THE FORMULACount=gcd(|Δx|,|Δy|)+1

A worked example

From (0,0) to (6,4), gcd(6,4)=2, so there are three points.

Good to know

A zero-length segment has one lattice point.

Read the result

Count integer-grid points on a segment without enumerating all intervening coordinates.

The primary result is labeled “Points including endpoints”. Keep the input definitions in view when comparing this result with another method.

Try a related calculation

A zero-length segment has one lattice point.

For a related exercise, try the circle calculator.

A few questions, answered

How can I check the default inputs by hand?

From (0,0) to (6,4), gcd(6,4)=2, so there are three points.

Which rule does this calculator apply?

Count=gcd(|Δx|,|Δy|)+1

Find your calculator

Start typing to explore the library.