Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6475235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:40:50+00:00 2026-05-25T06:40:50+00:00

I found this greatest common denominator code: def gcd(x,y): while y: x, y =

  • 0

I found this greatest common denominator code:

def gcd(x,y):
    while y:
        x, y = y, x % y
    return x

I cannot understand what we mean by while y as y is an integer. How does it work? Furthermore, what does the line x, y = y, x % y add to the code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:40:50+00:00Added an answer on May 25, 2026 at 6:40 am

    For while, read this: http://docs.python.org/reference/compound_stmts.html#the-while-statement

    It says “This repeatedly tests the expression and, if it is true, executes the first suite;”

    Now the question is: What’s True?

    Read this: http://docs.python.org/library/functions.html#bool

    Then read this: http://docs.python.org/library/stdtypes.html#truth-value-testing

    Non-zero values are True. Zero is false.

    What does the line “x, y=y, x%y” add to the code?

    Makes precious little sense as a question. “add to the code”? What? What part is confusing?

    Read this: http://docs.python.org/reference/simple_stmts.html#assignment-statements

    “If the target list is a comma-separated list of targets: The object must be an iterable with the same number of items as there are targets in the target list, and the items are assigned, from left to right, to the corresponding targets.”

    For the integer ‘%’ operator, read this: http://docs.python.org/library/stdtypes.html#numeric-types-int-float-long-complex

    It would help if your question was more specific. It’s hard to answer as asked.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found this code in a RailsCast : def tag_names @tag_names || tags.map(&:name).join(' ')
Reading this question I found this as (note the quotation marks) code to solve
I found this code. This is supposed to read framebuffer and save it as
I found this code for a replacement gotoxy() function using C standard library only.
I found this issue with distanceFromLocation function where the return value is not accurate.
I found this Perl script while migrating my SQLite database to mysql I was
I found this piece of code on Wikipedia. #include <stdio.h> int main(void) { int
I found this tutorial on using WIA in c++, but I don't understand how
Found this question here And I can't understand, why on first case it prints
I found this in a website while reading about virtual inheritance in c++ When

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.