JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.17/themes/start/jquery-ui.css" type="text/css" media="all" />
<style>
.effect { width: 240px; height: 100px; padding: 0.4em; position: relative; margin-bottom:1em; }
.effect h3 { margin: 0; padding: 0.4em; text-align: center; }
.ui-effects-transfer { border: 2px dotted gray; }
.center {margin-left: auto; margin-right: auto; width: 17em; }
</style>
<body style="background-color:#EEEEEE;">
<div class="center">
<div id="answer" title="respuesta ejercicio 1" style="display:none"></div>
<div class="effect ui-widget-content ui-corner-all">
Encontrar la suma de números enteros de todos los múltiplos de 3 o 5 menores que 1000. Ejemplo, 3 + 5 + 6 + 9 ....
</div>
<input type="button" id="run1" value="ejecutar ejercicio 1" >
<hr>
<div class="effect ui-widget-content ui-corner-all" style="height:180px !important;">
Escribir un programa que evalue los números enteros del 1 al 100, si el numero es multiplo de 3 imprimir Ying, si es multiplo de 5 imprimir Yang y si es múltiplo de ambos, 3 y 5, imprimir YingYang, si no es ninguno no imprimir nada. Ejemplo
3: Ying
5: Yang
6: Ying
....
15: YingYang
....
</div>
<input type="button" id="run2" value="ejecutar ejercicio 2" >
<div class="effect ui-widget-content ui-corner-all" style="Overflow: auto;" id="ans2"></div>
</div>
</body>
JavaScript
$(document).ready(function() {
$( "#answer" ).dialog({
autoOpen: false,
show: "slide",
hide: "drop"
});
$("#run1").button().click(function(){
$("#answer").html(problema1(1000,3,5));
$("#answer").dialog('open');
});
$("#run2").button().click(function(){
problema2(1000,3,5,$("#ans2"));
});
});
function problema1(max, num1, num2){
var count = 0;
var acc = 0;
for(count= 0; count<max; count++){
if(!(count%num1) || !(count%num2)){
acc += count;
}
}
return acc;
}
function problema2(max, num1, num2, mydiv){
mydiv.empty();
var count = 0;
var arr = Array;
for(count= 0; count<max; count++){
if(!(count%num1) && !(count%num2)){
mydiv.append(count + ": YingYang<br>");
} else
if(!(count%num1)){
mydiv.append(count + ": Ying<br>");
} else
if(!(count%num2)){
mydiv.append(count + ": Yang<br>");
} else {
//do nothing
}
}
}