-12
\$\begingroup\$

Use any programming language to display numbers divisible by 1000000 that are greater than 1 and less than 10000000. Each number should be displayed in new line. Your program should display exactly:

1000000
2000000
3000000
4000000
5000000
6000000
7000000
8000000
9000000
\$\endgroup\$
  • \$\begingroup\$ Hi, I closed your question as a duplicate of an older question, because the challenge specified there is pretty much the intent of this question. The other question is about testing divisibility between two numbers. \$\endgroup\$ – Erik the Outgolfer Oct 27 '18 at 17:42
  • 2
    \$\begingroup\$ @EriktheOutgolfer Not all answers here can be ported there, this one is more trivial. (being trivial should not be a reason for closing) \$\endgroup\$ – user202729 Oct 28 '18 at 15:02

16 Answers 16

3
\$\begingroup\$

Japt -R, 5 bytes

9õ*L³

Test it


Explanation

9õ        :Range [1,9]
  *       :Multiply each by
   L      :100
    ³     :Cubed
          :Implicitly join with newlines and output
\$\endgroup\$
3
\$\begingroup\$

Python 2, 29 bytes

i=0;exec'i+=10**6;print i;'*9

Try it online!

\$\endgroup\$
3
\$\begingroup\$

Bash, 13 bytes

seq {1,1,9}e6

Try it online!

This answer is found out by @manatwork

\$\endgroup\$
  • \$\begingroup\$ seq {1,1,9}e6 \$\endgroup\$ – manatwork Feb 21 at 9:13
  • \$\begingroup\$ @manatwork great! never heard such a notation before. \$\endgroup\$ – tsh Feb 21 at 9:38
  • \$\begingroup\$ Is just a usual brace expansion. echo seq {1,1,9}e6 will show you that it expands to your original code. \$\endgroup\$ – manatwork Feb 21 at 9:42
2
\$\begingroup\$

Whitespace, 85 bytes

[S S S N
_Push_0][N
S S N
_Create_Label_LOOP][S S S T N
_Push_1][T  S S S _Add][S N
S _Duplicate][S S S T   S T S N
_Push_10][T S S T   _Subtract][N
T   S S N
_If_0_Jump_to_Label_EXIT][S N
S _Duplicate][S S S T   T   T   T   T   S T S S S N
_Push_1000][S N
S _Duplicate][T S S N
_Multiply][T    S S N
_Multiply][T    N
S T _Print_number][S S S T  S T S N
_Push_10][T N
S S _Print_character][N
S N
N
_Jump_to_Label_LOOP]

Letters S (space), T (tab), and N (new-line) added as highlighting only.
[..._some_action] added as explanation only.

Try it online (with raw spaces, tabs and new-lines only).

Pseudo-code:

Integer i = 0
Start LOOP:
  i = i + 1
  If(i == 10):
    Exit with an error
  Integer j = 1000 * 1000 * i
  Print j as number to STDOUT
  Print "\n"
  Go to next iteration of LOOP
\$\endgroup\$
2
\$\begingroup\$

PowerShell, 14 bytes

1..9|%{$_*1e6}

Try it online!

Simply loops from 1 to 9 and multiplies each by 1e6, i.e., 1000000, to give the appropriate numbers. Ho-hum boring. Saved 7 bytes thanks to mazzy.

Previous versions:


PowerShell, 21 bytes

1..9|%{"$_"+"000000"}

Try it online!

Boring simple loop from 1 to 9 that just string-concatenates the output together.


PowerShell, 21 bytes

1e6..9e6|?{!($_%1e6)}

Try it online!

Loops from 1e6 to 9e6, pulls out those entries where they're divisible by 1e6. Times out on TIO but works offline. Run it with 3 instead of 6 to see the logic better.

\$\endgroup\$
  • \$\begingroup\$ ? 1..9|%{$_*1e6} \$\endgroup\$ – mazzy Oct 29 '18 at 21:19
  • \$\begingroup\$ @mazzy Of course! The most boring solution yet! Haha. \$\endgroup\$ – AdmBorkBork Oct 30 '18 at 12:35
1
\$\begingroup\$

Neim, 8 bytes

9Δμ7𝕎𝕋)_

Try it online!

\$\endgroup\$
1
\$\begingroup\$

05AB1E, 6 bytes

9L6°*»

Try it online.

Explanation:

9L        # List in the range [1,9]
  6°*     # Multiply each by 10**6
     »    # Join the list by newlines (and output implicitly)
\$\endgroup\$
1
\$\begingroup\$

Java 11, 62 61 56 54 bytes

v->{for(int i=0;i++<9;)System.out.println(i*1000000);}

-2 bytes thanks to @ggorlen.

Try it online.

Explanation:

v->{                        // Method with empty unused parameter and no return-type
  v->{for(int i=0;i++<9;)   //  Loop `i` in the range (0,9]
    System.out.println(     //   Print without trailing newline:
     i*1000000);}           //    `i` multiplied by 1,000,000
\$\endgroup\$
  • 1
    \$\begingroup\$ You could save a couple bytes with v->{for(int i=0;i++<9;)System.out.println(i*1000000);} \$\endgroup\$ – ggorlen Oct 30 '18 at 18:33
  • \$\begingroup\$ @ggorlen Can't believe I didn't check if that was shorter.. I did try printf("%.0f%n",i*1e6) and println((int)(i*1e6)) but forgot about just println(i*1000000).. Thanks! \$\endgroup\$ – Kevin Cruijssen Oct 30 '18 at 20:01
0
\$\begingroup\$

JavaScript (Node.js), 35 bytes

for(i=0;i++<9;)console.log(i*10**6)

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Attache, 16 bytes

Output[1:9*10^6]

Try it online!

Explanation

Output[1:9*10^6]
       1:9          the range from 1 to 9
          *10^6     multiplied by 10^6 (1e6)
Output[        ]    output each entry on its own line
\$\endgroup\$
0
\$\begingroup\$

///, 29 bytes

/!/000000
/1!2!3!4!5!6!7!8!9!

Try it online!

33 bytes for no trailing newline:

/"/000//!/""
/1!2!3!4!5!6!7!8!9""

Try it online!

\$\endgroup\$
0
\$\begingroup\$

C++ 44 bytes

for(int i=1;i<=9;i++){cout<<i*100**6<<endl;}
\$\endgroup\$
0
\$\begingroup\$

Retina, 16 bytes


9*
L$`.
$.>`6*0

Try it online! Explanation:


9*

Insert 9 _s.

L$`.

List a value for each _.

$.>`6*0

Number of characters up to and including the current _ followed by six zeros.

\$\endgroup\$
0
\$\begingroup\$

C# (.NET Core), 48 44 bytes

for(int i=0;i++<9;)Console.WriteLine(i*1e6);

Try it online!

-4 bytes: changed i*1000000 to i*1e6 in Console.WriteLine()

Ungolfed:

for (int i = 0; i++ < 9;)               // from 1 to 9
    Console.WriteLine(i * 1e6);     // write i times 1,000,000 (1e6 = 1*(10^6) = 1,000,000) to the console
\$\endgroup\$
0
\$\begingroup\$

APL (Dyalog Unicode), 7 bytesSBCS

Full program.

⍪1E6×⍳9

Try it online!

⍳9ɩndices one through nine

1E9× multiply million by those

 columnify

\$\endgroup\$
0
\$\begingroup\$

Python 3, 35 bytes

for i in range(1,10):print(i*10**6)

Try it online!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.