How can I print all the multiples of 5 from 5 to 1,000,000












-5















New to Python and having a hard time creating a for loop or while loop that'll give me an output of 5, 10 ,15, 20, ... all the way to 1,000,000.










share|improve this question




















  • 2





    I think the python range() object is what you want.

    – SuperShoot
    Nov 26 '18 at 3:21


















-5















New to Python and having a hard time creating a for loop or while loop that'll give me an output of 5, 10 ,15, 20, ... all the way to 1,000,000.










share|improve this question




















  • 2





    I think the python range() object is what you want.

    – SuperShoot
    Nov 26 '18 at 3:21
















-5












-5








-5








New to Python and having a hard time creating a for loop or while loop that'll give me an output of 5, 10 ,15, 20, ... all the way to 1,000,000.










share|improve this question
















New to Python and having a hard time creating a for loop or while loop that'll give me an output of 5, 10 ,15, 20, ... all the way to 1,000,000.







python






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 26 '18 at 5:20









SuperShoot

1,993921




1,993921










asked Nov 26 '18 at 3:20









Robin HartleyRobin Hartley

12




12








  • 2





    I think the python range() object is what you want.

    – SuperShoot
    Nov 26 '18 at 3:21
















  • 2





    I think the python range() object is what you want.

    – SuperShoot
    Nov 26 '18 at 3:21










2




2





I think the python range() object is what you want.

– SuperShoot
Nov 26 '18 at 3:21







I think the python range() object is what you want.

– SuperShoot
Nov 26 '18 at 3:21














3 Answers
3






active

oldest

votes


















1














Use range (note your doing to a million which is gonna take a while):



print(list(range(5,1000005,5)))





share|improve this answer
























  • This doesn't answer the "question" which explicitly "asks" for a for or while loop...

    – Julien
    Nov 26 '18 at 3:42



















1














total = 5
while total <= 1000000:
print(total)
total = total + 5





share|improve this answer































    1














    Try this



    for i in range(0,1000000,5):
    print(i)



    This will print every time it goes up by 5.
    The range() function works like range(start, stop, step)






    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53474379%2fhow-can-i-print-all-the-multiples-of-5-from-5-to-1-000-000%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      Use range (note your doing to a million which is gonna take a while):



      print(list(range(5,1000005,5)))





      share|improve this answer
























      • This doesn't answer the "question" which explicitly "asks" for a for or while loop...

        – Julien
        Nov 26 '18 at 3:42
















      1














      Use range (note your doing to a million which is gonna take a while):



      print(list(range(5,1000005,5)))





      share|improve this answer
























      • This doesn't answer the "question" which explicitly "asks" for a for or while loop...

        – Julien
        Nov 26 '18 at 3:42














      1












      1








      1







      Use range (note your doing to a million which is gonna take a while):



      print(list(range(5,1000005,5)))





      share|improve this answer













      Use range (note your doing to a million which is gonna take a while):



      print(list(range(5,1000005,5)))






      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Nov 26 '18 at 3:24









      U9-ForwardU9-Forward

      17.1k51743




      17.1k51743













      • This doesn't answer the "question" which explicitly "asks" for a for or while loop...

        – Julien
        Nov 26 '18 at 3:42



















      • This doesn't answer the "question" which explicitly "asks" for a for or while loop...

        – Julien
        Nov 26 '18 at 3:42

















      This doesn't answer the "question" which explicitly "asks" for a for or while loop...

      – Julien
      Nov 26 '18 at 3:42





      This doesn't answer the "question" which explicitly "asks" for a for or while loop...

      – Julien
      Nov 26 '18 at 3:42













      1














      total = 5
      while total <= 1000000:
      print(total)
      total = total + 5





      share|improve this answer




























        1














        total = 5
        while total <= 1000000:
        print(total)
        total = total + 5





        share|improve this answer


























          1












          1








          1







          total = 5
          while total <= 1000000:
          print(total)
          total = total + 5





          share|improve this answer













          total = 5
          while total <= 1000000:
          print(total)
          total = total + 5






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 26 '18 at 3:24









          John GordonJohn Gordon

          10.5k51831




          10.5k51831























              1














              Try this



              for i in range(0,1000000,5):
              print(i)



              This will print every time it goes up by 5.
              The range() function works like range(start, stop, step)






              share|improve this answer




























                1














                Try this



                for i in range(0,1000000,5):
                print(i)



                This will print every time it goes up by 5.
                The range() function works like range(start, stop, step)






                share|improve this answer


























                  1












                  1








                  1







                  Try this



                  for i in range(0,1000000,5):
                  print(i)



                  This will print every time it goes up by 5.
                  The range() function works like range(start, stop, step)






                  share|improve this answer













                  Try this



                  for i in range(0,1000000,5):
                  print(i)



                  This will print every time it goes up by 5.
                  The range() function works like range(start, stop, step)







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 26 '18 at 3:29









                  exeexe

                  13514




                  13514






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53474379%2fhow-can-i-print-all-the-multiples-of-5-from-5-to-1-000-000%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Wiesbaden

                      Marschland

                      Dieringhausen