This repository has been archived on 2022-06-22. You can view files and clone it, but cannot push or open issues or pull requests.
Idiot-Code-Golf/gcd/gcd.cpp

10 lines
319 B
C++

/*
Problem: Find the greatest common divisor of two numbers.
Solution: Euclidean algorithm except modulos are computed using trig functions!
*/
#include <bits/stdc++.h>
int gcd(int a,int b){while(a^b)std::swap(b,a=b*(M_PI/2-atan(cos(M_PI*a/b)/sin(M_PI*a/b)))/M_PI+1e-9);return a;}
int main(){std::cout<<gcd(126,84);}