Last active
May 9, 2020 21:14
Revisions
-
codingscode revised this gist
May 9, 2020 . 1 changed file with 10 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ var delta = 0 var mdc = 0 var resposta = 0 const minha_lista = [20, 16, 60] // function maior(matriz) { return matriz.reduce(function (a, b) { @@ -24,11 +24,16 @@ function achar_mdc(matriz, p) { }) } function tentativas(matriz, p) { while (achar_mdc(matriz, p) == false) { mdc = maior(matriz) - p p += 1 } return mdc } tentativas(minha_lista, delta) resposta = mdc - 1 console.log('maior elemento : ' + maior(minha_lista)) console.log('mdc: ' + resposta) -
codingscode revised this gist
May 9, 2020 . No changes.There are no files selected for viewing
-
codingscode revised this gist
May 8, 2020 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,11 +2,13 @@ var delta = 0 var mdc = 0 var resposta = 0 const minha_lista = [20, 16, 60] function maior(matriz) { return matriz.reduce(function (a, b) { return Math.max(a, b) }) } function resto0(numero, matriz, p) { if (numero % (maior(matriz) - p) == 0) { return true @@ -15,15 +17,18 @@ function resto0(numero, matriz, p) { return false } } function achar_mdc(matriz, p) { return (matriz).every((cada, indice) => { return resto0(cada, matriz, p) }) } while (achar_mdc(minha_lista, delta) == false) { mdc = maior(minha_lista) - delta delta += 1 } resposta = mdc - 1 console.log('maior: ' + maior(minha_lista)) console.log('mdc: ' + resposta) -
codingscode created this gist
May 8, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ var delta = 0 var mdc = 0 var resposta = 0 const minha_lista = [20, 16, 60] function maior(matriz) { return matriz.reduce(function (a, b) { return Math.max(a, b) }) } function resto0(numero, matriz, p) { if (numero % (maior(matriz) - p) == 0) { return true } else { return false } } function achar_mdc(matriz, p) { return (matriz).every((cada, indice) => { return resto0(cada, matriz, p) }) } while (achar_mdc(minha_lista, delta) == false) { mdc = maior(minha_lista) - delta delta += 1 } resposta = mdc - 1 console.log('maior: ' + maior(minha_lista)) console.log('mdc: ' + resposta)