id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

andersoniii.edwin@cusd80.com > EuclidAlgorithm
prev  |  next  |  chance

Euclid's algorithm is a method for finding the greatest common divisor (GCD) of two positive integers. It states that, for any two positive integers big and small such that big >= small (if big isn't >= small, then swap them). The GCD can be calculated as follows: 1. divide big by small to get the "remainder" (remember that big must be >= small and that remainder comes from MODULUS) 2. if the remainder is zero, then the GCD = small 3. otherwise set big equal to small and set small equal to the remainder 4. repeat steps 1, 2, and 3 until the remainder is zero


EuclidAlgorithm(12, 16) → 4
EuclidAlgorithm(24, 12) → 12
EuclidAlgorithm(13, 14) → 1

...Save, Compile, Run (ctrl-enter)

public int EuclidAlgorithm(int num1, int num2) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 145

Copyright Nick Parlante 2017 - privacy