logo elektroda
logo elektroda
X
logo elektroda

[C++] How to Calculate GCW and GCD for Two Numbers Using an Algorithm

sp33dway 21702 3
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 7173036
    sp33dway
    Level 10  
    problem solved
  • ADVERTISEMENT
  • #2 7173560
    Terminator
    Level 23  
    If you already have the GCD, what's the problem to calculate NWW (or here )?

    edit:
    [code:1:53670cdbe7]#include

    int main()
    {

    int a,b;
    std::cout > a;
    std::cout > b;
    //zapamietaj
    int azap = a, bzap = b;
    while (a!=b)
    {
    if (b>a)
    b-=a;
    else
    a-=b;
    }
    std::cout
  • ADVERTISEMENT
  • #3 7173750
    sp33dway
    Level 10  
    please delete the post :D
  • #4 8970706
    El Polacco
    Level 11  
    And are you able to convert it for me so that it calculates for n natural numbers, and not just 2 numbers?
ADVERTISEMENT