Skip to content
Ta180m  /   Idiot-Code-Golf  /   Discussions #12  /  
  • Unwatch 1

    Notifications

    Get push notifications on iOS or Android.
  • Fork 0

Problem 2: GCD #12

Unanswered
Ta180m asked this question in Q&A
Problem 2: GCD #12
on Apr 30, 2021 · 1 answer

The greatest common divisor is a common number theory operation.

Here's a few implementations to give you some ideas:

int gcd(int a,int b){while(b)b^=a^=b^=a%=b;return a;}
int gcd(int a,int b){while(a&&b)a>b?a%=b:b%=a;return a+b;}

Replies

1 suggested answer

Ta180m
on Apr 30, 2021
Maintainer Author

https://github.com/Ta180m/Idiot-Code-Golf/blob/main/gcd/gcd.cpp

Euclidean algorithm except modulos are computed using trig functions!

0 replies
@Ta180m
Select a reply ctrl .
Remember, contributions to this repository should follow our GitHub Community Guidelines.
Category
Change category
Q&A
Labels
None yet
1 participant
  • Lock conversation

    Lock conversation on this discussion

    • Other users can’t add new comments to this discussion.
    • You and other collaborators with access to this repository can still leave comments that others can see.
    • You can always unlock this discussion again in the future.
  • Transfer discussion
  • Pin discussion

    Configure pinned discussion

    Up to 4 discussions can be pinned and they will appear publicly at the top of the discussions page.

  • Create issue from discussion
  • Delete discussion?

    The discussion will be deleted permanently. You will not be able to restore the discussion or its comments