Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

50%
+0 −0
Challenges Getting perfect squares, differently

C (clang), 47 45 43 bytes i,j;main(){for(;printf("%i ",i-=~j);j+=2);} Try it online! Golfed 2 bytes from inspiration of @Shaggy's answer. Golfed 2 bytes by @m90.

posted 3y ago by General Sebast1an‭  ·  edited 3y ago by General Sebast1an‭

Answer
#4: Post edited by user avatar General Sebast1an‭ · 2021-08-12T15:13:35Z (about 3 years ago)
  • # [C (clang)], <s>47</s> 45 bytes
  • <!-- language-all: lang-c -->
  • i,j;main(){for(j=1;printf("%i ",i+=j);j+=2);}
  • [Try it online!][TIO-ks8xvti7]
  • Golfed 2 bytes from inspiration of [**@Shaggy**](https://codegolf.codidact.com/users/53588)['s answer](https://codegolf.codidact.com/posts/283341/283345#answer-283345).
  • [C (clang)]: http://clang.llvm.org/
  • [TIO-ks8xvti7]: https://tio.run/##S9ZNzknMS/@vnJmXnFOakqpgU1ySkpmvl2H3P1Mnyzo3MTNPQ7M6Lb9II8vW0LqgKDOvJE1DSTVTQUknU9s2S9M6S9vWSNO69v9/AA "C (clang) – Try It Online"
  • # [C (clang)], <s>47</s> <s>45</s> 43 bytes
  • <!-- language-all: lang-c -->
  • i,j;main(){for(;printf("%i ",i-=~j);j+=2);}
  • [Try it online!][TIO-ks927ic2]
  • Golfed 2 bytes from inspiration of [**@Shaggy**](https://codegolf.codidact.com/users/53588)['s answer](https://codegolf.codidact.com/posts/283341/283345#answer-283345). Golfed 2 bytes by [**@m90**](https://codegolf.codidact.com/users/54227).
  • [C (clang)]: http://clang.llvm.org/
  • [TIO-ks927ic2]: https://tio.run/##S9ZNzknMS/@vnJmXnFOakqpgU1ySkpmvl2H3P1Mnyzo3MTNPQ7M6Lb9Iw7qgKDOvJE1DSTVTQUknU9e2LkvTOkvb1kjTuvb/fwA "C (clang) – Try It Online"
#3: Post edited by user avatar General Sebast1an‭ · 2021-08-12T13:11:46Z (about 3 years ago)
  • # [C (clang)], 47 bytes
  • <!-- language-all: lang-c -->
  • i,j;main(){for(j=1;printf("%i ",i);i+=j,j+=2);}
  • [Try it online!][TIO-ks8szfkr]
  • Applies the equation from [Somewhere Else](https://math.stackexchange.com/a/3946753/939194).
  • [C (clang)]: http://clang.llvm.org/
  • [TIO-ks8szfkr]: https://tio.run/##S9ZNzknMS/@vnJmXnFOakqpgU1ySkpmvl2H3P1Mnyzo3MTNPQ7M6Lb9II8vW0LqgKDOvJE1DSTVTQUknU9M6U9s2SydL29ZI07r2/38A "C (clang) – Try It Online"
  • # [C (clang)], <s>47</s> 45 bytes
  • <!-- language-all: lang-c -->
  • i,j;main(){for(j=1;printf("%i ",i+=j);j+=2);}
  • [Try it online!][TIO-ks8xvti7]
  • Golfed 2 bytes from inspiration of [**@Shaggy**](https://codegolf.codidact.com/users/53588)['s answer](https://codegolf.codidact.com/posts/283341/283345#answer-283345).
  • [C (clang)]: http://clang.llvm.org/
  • [TIO-ks8xvti7]: https://tio.run/##S9ZNzknMS/@vnJmXnFOakqpgU1ySkpmvl2H3P1Mnyzo3MTNPQ7M6Lb9II8vW0LqgKDOvJE1DSTVTQUknU9s2S9M6S9vWSNO69v9/AA "C (clang) – Try It Online"
#2: Post edited by user avatar General Sebast1an‭ · 2021-08-12T13:04:20Z (about 3 years ago)
  • # [C (clang)], 47 bytes
  • <!-- language-all: lang-c -->
  • i,j;main(){for(j=1;printf("%i ",i);i+=j,j+=2);}
  • [Try it online!][TIO-ks8szfkr]
  • [C (clang)]: http://clang.llvm.org/
  • [TIO-ks8szfkr]: https://tio.run/##S9ZNzknMS/@vnJmXnFOakqpgU1ySkpmvl2H3P1Mnyzo3MTNPQ7M6Lb9II8vW0LqgKDOvJE1DSTVTQUknU9M6U9s2SydL29ZI07r2/38A "C (clang) – Try It Online"
  • # [C (clang)], 47 bytes
  • <!-- language-all: lang-c -->
  • i,j;main(){for(j=1;printf("%i ",i);i+=j,j+=2);}
  • [Try it online!][TIO-ks8szfkr]
  • Applies the equation from [Somewhere Else](https://math.stackexchange.com/a/3946753/939194).
  • [C (clang)]: http://clang.llvm.org/
  • [TIO-ks8szfkr]: https://tio.run/##S9ZNzknMS/@vnJmXnFOakqpgU1ySkpmvl2H3P1Mnyzo3MTNPQ7M6Lb9II8vW0LqgKDOvJE1DSTVTQUknU9M6U9s2SydL29ZI07r2/38A "C (clang) – Try It Online"
#1: Initial revision by user avatar General Sebast1an‭ · 2021-08-12T10:54:14Z (about 3 years ago)
# [C (clang)], 47 bytes

<!-- language-all: lang-c -->

    i,j;main(){for(j=1;printf("%i ",i);i+=j,j+=2);}

[Try it online!][TIO-ks8szfkr]

[C (clang)]: http://clang.llvm.org/
[TIO-ks8szfkr]: https://tio.run/##S9ZNzknMS/@vnJmXnFOakqpgU1ySkpmvl2H3P1Mnyzo3MTNPQ7M6Lb9II8vW0LqgKDOvJE1DSTVTQUknU9M6U9s2SydL29ZI07r2/38A "C (clang) – Try It Online"