locked
small basic projects RRS feed

  • Question

  • how to write program for calculating the amount of N natural numbers. Example, if N = 6, should be counted 1 +2 +3 +4 +5 +6. can someone help me ,, plss
    Monday, February 3, 2014 5:44 PM

Answers

    • Proposed as answer by Jibba j Thursday, February 6, 2014 6:27 PM
    • Marked as answer by Jibba j Friday, February 14, 2014 7:58 PM
    Monday, February 3, 2014 6:21 PM
  • n = Math.Round(TextWindow.ReadNumber())
    
    While n > 0
      sum = sum + n
      n = n - 1
    EndWhile
    
    TextWindow.WriteLine(sum)

    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    • Edited by GoToLoopEditor Monday, February 3, 2014 6:27 PM
    • Proposed as answer by Jibba j Thursday, February 6, 2014 6:24 PM
    • Marked as answer by Jibba j Friday, February 14, 2014 7:58 PM
    Monday, February 3, 2014 6:22 PM
    Answerer

All replies

    • Proposed as answer by Jibba j Thursday, February 6, 2014 6:27 PM
    • Marked as answer by Jibba j Friday, February 14, 2014 7:58 PM
    Monday, February 3, 2014 6:21 PM
  • n = Math.Round(TextWindow.ReadNumber())
    
    While n > 0
      sum = sum + n
      n = n - 1
    EndWhile
    
    TextWindow.WriteLine(sum)

    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    • Edited by GoToLoopEditor Monday, February 3, 2014 6:27 PM
    • Proposed as answer by Jibba j Thursday, February 6, 2014 6:24 PM
    • Marked as answer by Jibba j Friday, February 14, 2014 7:58 PM
    Monday, February 3, 2014 6:22 PM
    Answerer