1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Juli2301 [7.4K]
3 years ago
9

Write a function gcd(x, y) that returns the greatest common divisor of the parameters x and y. Use the Euclidean algorithm to do

this. Return None if the gcd does not exist(i.e., if both parameters are 0)
Computers and Technology
1 answer:
ddd [48]3 years ago
8 0

Answer:

function gcd(x,y) {

if (!y && !x) return 'None';

if (!y) return x;

return gcd(y, x%y);

}

console.log(gcd(462, 910));

console.log(gcd(0, 0));

console.log(gcd(32, 40));

Explanation:

This example is in javascript.

You might be interested in
Given that n refers to a positive integer, use a while loop to compute the sum of the cubes of the first n counting numbers, and
Rasek [7]

Answer:

int k = 1;

int total = 0;

while (k <= n){

  total = total + (k*k*k);

  k++;

}

Explanation:

The code above has been written in Java.

Following is the line-by-line explanation of the code written as comments.

// Initialize int variable k to 1.

// variable k is used to control the loop.

// It is initialized to 1 because the positive integers should start at 1.

// Starting at zero will be unimportant since the cube of 0 is still zero and

// has no effect on the overall sum of the cubes.

int k = 1;

// Initialize total to zero(0)

// This is so because, at the start of the addition total has no value.

// So giving it zero allows to cumulatively add other values to it.

// Variable <em>total </em>is also of type int because the sum of the cubes of counting

// numbers (which are positive integers) will also be an integer

int total = 0;

// Now create a while loop to repeatedly compute the sum of the cubes

// while incrementing the counter variable <em>k</em>.

// The condition for the loop to execute is when <em>k</em> is less than or equal to

// the value of variable <em>n.</em>

// The cube of any variable k is given by k^{3} which can be

// written as k * k * k.

// At every cycle of the loop, the cube of the counter <em>k</em> is calculated and

// added cumulatively to the value of <em>total</em>. The result is still stored in the

// variable <em>total. </em>After which <em>k</em> is incremented by 1 (k++).

while (k <= n) {

  total = total + (k*k*k);

  k++;

}

6 0
4 years ago
FREEEEE 100 POINTS COME TAKE COME COME COME<br><br> only if u like da black panther
sergejj [24]
He’s my love hehe JSJSJ

6 0
3 years ago
Read 2 more answers
If you were creating a program that would convert Fahrenheit to Celsius, which kind of variable would you want to use? a string
Arlecino [84]

Answer:

an integer because it is the most common form of the atom and the same way it is used to be used to describe the same type of them

5 0
3 years ago
Read 2 more answers
Cuales son las paginas web​
Feliz [49]
I don’t know what you mean but

Magazine websites. — ...
E-commerce websites. — ...
Blogs. — ...
Portfolio websites. — ...
Landing pages. — ...
Social media websites. — ...
Directory and contact pages
8 0
3 years ago
Dynamic addressing: __________.
Anarel [89]

Explanation:

jwjajahabauiqjqjwjajjwwjnwaj

6 0
3 years ago
Read 2 more answers
Other questions:
  • Keion works as a freelancer creating websites and designing logos for clients. He recently had a hard drive failure and lost wor
    7·1 answer
  • Jason is computer professional who has access to sensitive information. He shares this information with another organization in
    7·2 answers
  • The length of time the valve is open, expressed in degrees of crankshaft rotation, is called camshaft
    10·1 answer
  • You have just created a one-way incoming trust in your domain for an external domain used by a partner company to allow your dom
    11·1 answer
  • This type of connection uses radio waves to connect devices on a network.A) DataB) EthernetC) RouterD) wifi
    15·1 answer
  • State the seven common measures of queuing system performance ? State the assumptions of the “basic” single-server queuing model
    10·1 answer
  • Write a program in java using switch case statement
    11·1 answer
  • Can anyone help me with a mental ability work plzz
    12·1 answer
  • What note for percussun is this??
    12·1 answer
  • If you’d like to have multiple italicized words in your document, how would you change the font of each of these words
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!