Write a function named myFunction(x) who accepts an input integer x and returns an integer n, such that 1+2+...+n is just over x or exactly equal to x for example, input x=4 should return 3 input x=10 should return 4 I. input x=7 shoud return 4 Note, use while-loop, running_sum, count. Function e
Write a function named myFunction(x) who accepts an input integer x and returns an integer n, such that 1+2+...+n is just over x or exactly equal to x for example, input x=4 should return 3 input x=10 should return 4 I. input x=7 shoud return 4 Note, use while-loop, running_sum, count. Function e
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Please help me with this Homework
Expert Solution
Step 1
EXPLANATION -
- Main function is created .
- Two variable are created p and x .
- Input from user is taken in variable x .
- Function named as myFunction is called and value x is passed .
- In myFunction function two variable are declared and initialized as 0 .
- While loop is created .
- Condition is added where the loop will keep executing until value or running_sum is less than x .
- It while loop body value of running sum with +1 incremented value is kept adding .
- and value of count is kept incremented by 1 .
- After end of loop .
- Value of count is returned .
- Returned value is stored in p .
- Value of p is displayed .
- End of Program.
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 4 images
Knowledge Booster
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.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education