Contact
Privacy
Coding Development Art
  • Home
  • Latest
  • Oldest
  • Popular
  • Random
  • Home»
  • Categrories»
  • Programming Languages»
  • Python»

Write a python function that returns the sum of n natural numbers - Python

Categories:
Python
Viewed: 3 - Published at: a few seconds ago

[ Write a python function that returns the sum of n natural numbers ]

def sum_natural(num):
    if num < 0:
       print("Please enter a positive number!")
    else:
       sum = 0
       while(num > 0):
           sum += num
           num -= 1
       return num

Related Posts:

Graphs in Java - A* Algorithm
Graphs in Java - A* Algorithm
Algorithm
How can I get a list of tables connected to each module in AX 09?
How can I get a list of tables connected to each module in AX 09?
Can I bin deploy and MVC4 for .NET 4 where I have an MVC3 app running?
Can I bin deploy and MVC4 for .NET 4 where I have an MVC3 app running?
How can I get jcifs to play nicely with apache axis
How can I get jcifs to play nicely with apache axis
Java
having difficulty with xml writing
having difficulty with xml writing
Android
FPDF multicell alignment not working
FPDF multicell alignment not working
PHP

You may also like:

C++ Program to do arithmetic operations according to user choice using switch case
C++ Program to do arithmetic operations according to user choice using switch case
C++ Programs
Matplotlib Box Plot - Tutorial and Examples
Matplotlib Box Plot - Tutorial and Examples
Python
Padding Strings in Python
Padding Strings in Python
Python
JavaScript: How to Sleep/Wait/Delay Code Execution
JavaScript: How to Sleep/Wait/Delay Code Execution
JavaScript
define a string in spring context
define a string in spring context
android fragment replacing and removing
android fragment replacing and removing
Android
Categories
  • Blog
    • Career
    • Computer
    • Downloads
    • Internet
    • Linux
    • News
    • Review
    • Security
    • Technology
  • Database
    • MySql
    • Oracle Database
    • SQL Server
    • SQLite
    • mongodb
  • Dev
    • Algorithm
    • Android
    • Batch File Programming
    • Books
    • Competitive Programming
    • Computer Networks
    • Data Structure
    • Design
    • Development
    • Flutter
    • Game
    • Git
    • Interview Questions
    • JDBC
    • Machine Learning
    • Mobile
    • Operating System
    • Programming
    • Projects
    • Sponsored
    • Webservice
    • iOS
  • Framework
    • .NET
    • Angular
    • Django
    • MVC
    • Nodejs
    • React
  • Programming Languages
    • ASP.NET
    • C Programs
    • C#
    • C++ Programs
    • CSS
    • HTML
    • JSP
    • Java
    • JavaScript
    • PHP
    • PL/SQL
    • Python
    • SQL
    • Swift
    • VB.NET
  • Tools
    • privacy-policy-generator
    • Mac Vendors
    • Ports Numbers
    • Wifi Routers Passwords

Site all the data, are collected from Internet, belongs to original author, please do not used for commercial purposes !

Coding Development Art
  https://www.codevelop.art
 
  contact@codevelop.art

Posts

  • Home
  • Latest
  • Oldest
  • Popular
  • Random

Follow Us

© 2018 codevelop.art - Coding Develop Art - programming and development tutorials blog - Learn all Program languages | codevelop.art.
All Rights Reserved.
  • Contact
  • Privacy
  • Terms of service
  • Copyright
  • Disclaimer