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 8, Problem 8PE
Program Plan Intro

Greatest Common Divisor

Program Plan:

  • Declare a main function. Inside the main function,
    • Get the two numbers from the user.
    • In the “try’ block,
      • Check “m” value is less than “n” value.
        • Swap the values.
      • Check “m” value is not equal to 0.
        • Set the value
        • Calculate the “m” value
        • Again, set the value.
      • Display the result.
    • In exception block, display the error message.
  • Call the main function.

Blurred answer
Students have asked these similar questions
Correct answer will be upvoted else downvoted.   number is called 2050-number if it is 2050, 20500, ..., (2050⋅10k for integer k≥0).   Given a number n, you are asked to represent n as the sum of some (not necessarily distinct) 2050-numbers. Compute the minimum number of 2050-numbers required for that.   Input The first line contains a single integer T (1≤T≤1000) denoting the number of test cases.   The only line of each test case contains a single integer n (1≤n≤1018) denoting the number to be represented.   Output For each test case, output the minimum number of 2050-numbers in one line.   If n cannot be represented as the sum of 2050-numbers, output −1 instead.
Correct answer will be upvoted else downvoted. Computer science.    You are given an integer n. Check if n has an odd divisor, more noteworthy than one (does there exist such a number x (x>1) that n is separable by x and x is odd).    For instance, assuming n=6, there is x=3. Assuming n=4, such a number doesn't exist.    Input    The primary line contains one integer t (1≤t≤104) — the number of experiments. Then, at that point, t experiments follow.    Each experiment contains one integer n (2≤n≤1014).    If it's not too much trouble, note, that the input for some experiments will not squeeze into 32-cycle integer type, so you should use no less than 64-digit integer type in your programming language.    Output    For each experiment, output on a different line:    "Indeed" if n has an odd divisor, more noteworthy than one;    "NO" in any case.    You can output "YES" and "NO" regardless (for instance, the strings yEs, indeed, Yes and YES will be perceived as certain).
Start with a pile of n stones and successively split a pile into two smaller piles until each pile has only one Each time a split happens, multiply the number of stones in each of the two smaller piles. (For example, if a pile has 15 stones and you split it into a pile of 7 and another pile of 8 stones, multiply 7 and 8.)  The goal of this problem is to show that no matter how the  pile of n  stones are split, the sum of the products computed at each split is equal to n(n - 1)/2. Using strong mathematical induction, prove that no matter how the pile of n stones are split, the sum of the products computed at each split is equal to n(n - 1)/2.
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++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
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