Python Programming: An Introduction to Computer Science, 3rd Ed.
Python Programming: An Introduction to Computer Science, 3rd Ed.
3rd Edition
ISBN: 9781590282755
Author: John Zelle
Publisher: Franklin, Beedle & Associates
bartleby

Videos

Question
Book Icon
Chapter 3, Problem 11PE
Program Plan Intro

Sum of first n natural numbers

Program Plan:

  • Define the main function.
    • Get the value of “n” from the user.
    • Declare a variable “sum” and assign 0 to it.
    • Loop from 0 through n.
      • Calculate the value of sum and store it in a variable “sum”.
    • Print the value of “sum”.

Blurred answer
Students have asked these similar questions
Write a program that calculates the sum of all positive integers less than or equal to a given number N.
/*code   Kth Largest Factor   A positive integer d is said to be a factor of another positive integer N if when N is divided by d, the remainder obtained is zero. For example, for number 12, there are 6 factors 1, 2, 3, 4, 6, 12. Every positive integer k has at least two factors, 1 and the number k itself.Given two positive integers N and k, write a program to print the kth largest factor of N.       Input Format: The input is a comma-separated list of positive integer pairs (N, k).       Output Format: The kth highest factor of N. If N does not have k factors, the output should be 1.       Constraints:       1<N<10000000000   1<k<600.   You can assume that N will have no prime factors which are larger than 13..
A palindromic number is a number that is the same when written forwards or backwards. The first few palindromic numbers are therefore are:   0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99, 101, 111, 121, 323   Input a number from the user. Write a program that reverses the digits of a number. Use this program to find if the number is a palindrome. Print if the number is palindrome or not.
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY