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

Looping counter

+10
−0

Looping counter

Create an infinite loop that outputs lines of asterisks, with each line containing one more asterisk. Instead of the asterisk, any printable, non-whitespace character can be used. However all lines need to use the same character.

The beginning of the output looks like this:

*
**
***
****
*****
******
*******
********
*********
**********
***********
************

An ungolfed Python implementation:

from itertools import count

for i in count(1):
    print('*'*i)
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

2 comment threads

Minimum maximum (1 comment)
Output line 0. Input for starting line (1 comment)

21 answers

You are accessing this answer with a direct link, so it's being shown above all other answers regardless of its score. You can return to the normal view.

+1
−0

Embed ESCR, about 32 characters depending on how you count

loop
  append s "*"
  show s
  endloop

The indentation is not required, but shown for clarity. Declaring the variable S is also not included, since similar stuff doesn't seem to be included in other examples.

S is a string variable. In ESCR, storage for a string can grow dynamically at run time as needed. The string initialially starts empty, with one "*" appended to it each iteration.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+5
−0

Lua, 31 bytes

_=''::_::_=_..'*'print(_)goto _

Try it online!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

1 comment thread

You can shorten your loop by using goto. As a bonus, this makes your code look even more cryptic (: ... (2 comments)
+3
−0

Vyxal, 5 4 bytes

¤{‹…

Try it Online!

This is so stupid and I love it

Explained

¤{‹…
¤     # Push an empty string
 {    # Forever:
  ‹   #   Append a "-" to the top of the stack
   …  #   And print it without popping
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+3
−0

Ruby, 18 bytes

loop{$><<$/=?*+$/}

Try it online!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+2
−0

Haskell, 35 bytes

main=mapM putStrLn$iterate('*':)"*"

Attempt This Online!

55 -> 39, with orthoplex's idea.

39 -> 35 from orthoplex.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

1 comment thread

Neat solution, but that import is quite expensive. Maybe try something like ```haskell x="*":map('*... (3 comments)
+2
−0

MATL, 16 bytes

1`1yh1$lZctDwQt]

Try it online!

The TIO output fetch will likely fail, so make sure to click the run button to stop the execution.

1`1yh1$lZctDwQt]
1`             ] - Push 1 onto stack, enter do-while
  1              - Push 1 onto stack
   y             - duplicate n-th level of stack, default is 2
    h            - horzcat, 1 10h -> [1;10]
     1$l         - ones, specifying arguments with 1$
        Zc       - strjoin
          t      - duplicate top of stack
           D     - display
            w    - swap
             Q   - increment by 1
              t  - duplicate

Matlab can loop infinitely using k=1:inf, but MATL cannot perform [1:Y] where Y is shorthand for inf.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+2
−0

brainfuck, 31 bytes

++++++++++[[>]>-[<+>---]<[.<]>]

Try it online!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+1
−0

Python 3, 28 bytes

_=""
while 1:_+="*";print(_)

Try it online!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+1
−0

J, 13 char

'*',^:(<_)'*'

How it works: What's in parenthesis indicates to the verb ^: that the verb to the left of ^: has to be performed to the object on the right of the ^: an infinite number of times and that it has to list each intermediate result. '_' is infinity, and '<' boxes it to force listing the intermediate results.

   '*',^:(<4)'*'
*   
**  
*** 
****
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+1
−0

Fig, 5 bytes

The actual score is $5\log_{256}(96)\approx$ 4.116 bytes. The leaderboard only likes ints in the header.

(J,Q0

-1 char thanks to Seggan

Try it online!

Fractional byte lang created by Seggan. Is this even allowed here?

(J,Q0
  ,Q    : Print and return last return value, initialized as 0
 J  0   : Add 0 to end of result
(       : Loop forever
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

1 comment thread

The leaderboard thinks this is 116 bytes lol. You might want to change it to 4 or 5 (2 comments)
+1
−0

K (oK), 9 bytes

{x#0}'!10

Try it online!

         !10   / pass range your arbitrary number
       .'      / treat those as a list, and evaluate each separately
{     }        / main function
 x             / number passed from the list
  #            / will be 'counted' x many times
   0           / printing the 0 each time
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

1 comment thread

Invalid (1 comment)
+1
−0

Bash, 17 bytes

echo x$1;./$0 x$1

Try it online!

Thanks to celtschk‭ for spotting my mistake :)

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

1 comment thread

Wrong output (1 comment)
+1
−0

C, 30 + 1-4 byte

f(m){f(printf("%0*i\n",m,0));}

Has this limitations:

  • counter stops working at INT_MAX or at stack overflow.
  • Needs a input value to indicate on which line we start. 0 starts on the line with one character.
  • It uses 0 and not * as output character

Because of the additional input number, i added the + 1 in the title. If you call the program, you need to write f(0), this is why the +4 in the title.

Fully working program, 36 byte:

main(m){main(printf("%0*i\n",m,0));}
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+1
−0

><>, 10 bytes

1:naoa*1+!

Try it online!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+1
−0

JavaScript (Node.js), 31 bytes

for(i='';;console.log(i+='*'));

Try it online!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+1
−0

C (gcc), 47 bytes

i,n;f(){for(i=n+++2;i--;)putchar(i?42:13);f();}

Try it online!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+1
−0

dc, 13 bytes

[r1+pA*rdx]dx

Try it online!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+1
−0

JavaScript, 25 bytes

Could be 21 but calling the function like that feels like cheating.

(f=s=>f(s+=8,print(s)))``

Try it online!

22 bytes

Didn't want to post this as my main solution as it's pretty much the same as Moshi's.

for(s=``;;)print(s+=8)

Try it online!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+1
−0

Japt, 6 bytes

ßOpP±Q

Test it

ßOpP±Q
ß          :Recursive call
 Op        :Output with trailing newline
   P       :Empty string, initially
    ±      :Append
     Q     :Quotation mark
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+1
−0

Python 2, 26 bytes

_=1
while 1:_*=10;print~-_

Try it online!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

1 comment thread

3.x compatibility (1 comment)

Sign up to answer this question »