Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Question

Tweeted twitter.com/StackCodeGolf/status/826440560936353792
added 23 characters in body
Source Link
orlp
  • 39.4k
  • 8
  • 82
  • 197

Write a program or function that given an integer radius r returns the number of unit squares the circle with radius r centered at the origin passes through. If the circle passes exactly through a point on the grid that does not count as passing through the adjacent unit squares.

Here's an illustration for r = 5:

illustration Illustration by Kival Ngaokrajang, found on OEIS

Examples:

0 → 0
1 → 4
4 → 28
5 → 28
49 → 388
50 → 380
325 → 2540
5524 → 44180
5525 → 44020

Write a program or function that given an integer radius r returns the number of unit squares the circle with radius r centered at the origin passes through. If the circle passes exactly through a point on the grid that does not count as passing through the adjacent unit squares.

Here's an illustration for r = 5:

illustration Illustration by Kival Ngaokrajang, found on OEIS

Examples:

0 → 0
1 → 4
4 → 28
49 → 388
50 → 380
325 → 2540
5524 → 44180
5525 → 44020

Write a program or function that given an integer radius r returns the number of unit squares the circle with radius r centered at the origin passes through. If the circle passes exactly through a point on the grid that does not count as passing through the adjacent unit squares.

Here's an illustration for r = 5:

illustration Illustration by Kival Ngaokrajang, found on OEIS

Examples:

0 → 0
1 → 4
4 → 28
5 → 28
49 → 388
50 → 380
325 → 2540
5524 → 44180
5525 → 44020

added 61 characters in body
Source Link
orlp
  • 39.4k
  • 8
  • 82
  • 197

Write a program or function that given an integer radius r returns the number of unit squares the circle with radius r centered at the origin passes through. If the circle passes exactly through a point on the grid that does not count as passing through the adjacent unit squares.

Here's an illustration for r = 5:

illustration Illustration by Kival Ngaokrajang, found on OEIS

Examples:

0 → 0
1 → 4
4 → 28
49 → 388
50 → 380
325 → 2540
5524 → 44180
5525 → 44020

Write a program or function that given an integer radius r returns the number of unit squares the circle with radius r centered at the origin passes through. If the circle passes exactly through a point on the grid that does not count as passing through the adjacent unit squares.

Here's an illustration for r = 5:

illustration

Examples:

0 → 0
1 → 4
4 → 28
49 → 388
50 → 380
325 → 2540
5524 → 44180
5525 → 44020

Write a program or function that given an integer radius r returns the number of unit squares the circle with radius r centered at the origin passes through. If the circle passes exactly through a point on the grid that does not count as passing through the adjacent unit squares.

Here's an illustration for r = 5:

illustration Illustration by Kival Ngaokrajang, found on OEIS

Examples:

0 → 0
1 → 4
4 → 28
49 → 388
50 → 380
325 → 2540
5524 → 44180
5525 → 44020

edited tags
Link
Martin Ender
  • 198.2k
  • 67
  • 455
  • 998
Source Link
orlp
  • 39.4k
  • 8
  • 82
  • 197
Loading

AltStyle によって変換されたページ (->オリジナル) /