Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • 1
    \$\begingroup\$ Hi, welcome to CGCC. You can golf your answer by using for-loops instead of while-loops. Also, you currently have a hard-coded upper-bound of 2,000,000 (\$2\times1000^2\$), so you might want to mention that in your answer. Both shorter and more correct would be to use the input n instead of 1e3 though: 74 bytes \$\endgroup\$ Commented Feb 7, 2022 at 9:49
  • 1
    \$\begingroup\$ Also, if you haven't seen it yet, tips for golfing in C and tips for golfing in <all languages> might be interesting to read through. :) \$\endgroup\$ Commented Feb 7, 2022 at 9:50
  • 1
    \$\begingroup\$ Using a global variable as you did it's not allowed , you can pass a pointer. Here a small golf for you, and welcome to code golf \$\endgroup\$ Commented Feb 7, 2022 at 12:39
  • \$\begingroup\$ @AZTECCO What does g=g mean?:) \$\endgroup\$ Commented Feb 7, 2022 at 12:49
  • 2
    \$\begingroup\$ See this. Magic GCC stuff. But if you use this trick, the language you're competing in is C (GCC -O0) \$\endgroup\$ Commented Feb 7, 2022 at 13:12