Versionsvergleich
Aus ProgrammingWiki
Vergleich: 2021-06-17T18:20:30+00:00 → 2021-06-17T18:23:12+00:00
<language>Javascript</language> | |
== Folie 24 == | |
<code id="60cb81bc7ee4a"> | |
function h(x,y){ | |
if(x%2+y==0) | |
return y; | |
else | |
return h(x,y+1); | |
} | |
</code> | |
<run id="60cb81bc7f007"> | |
h(10,0) | |
</run> | |
Wenn x gerade, dann 0, sonst ⊥ | |
== Folie 26 == | |
<code id="60cb81bc7eec1"> | |
function h1(x,y){ | |
if(x%2-y==0) | |
return y; | |
else | |
return h1(x,y+1); | |
} | |
</code> | |
<run id="60cb81bc7f073"> | |
h1(10,0) | |
</run> | |
Wenn x gerade, dann 0, sonst 1 | |
== Folie 28 == | |
| − | <code id="60cb81bc7ef38"> |
| + | <code id="60cb92aec4383"> |
| + | |
function monus(x,y){ | |
if(x<=y) | |
return 0 | |
else | |
return x-y; | |
} | |
function h2(x,y){ | |
if(monus(Math.pow(x, 2),y)==0) | |
return y; | |
else | |
return h2(x,y+1); | |
} | |
</code> | |
| − | <run id="60cb81bc7f0d5"> |
| + | <run id="60cb92aec4429"> |
h2(10,0) | |
</run> | |
x-quadrat | |
== Folie 30 == | |
| − | <code id="60cb81bc7ef93"> |
| + | <code id="60cb931024657"> |
function h3(x,y){ | |
| − | if(Math.pow(y, 2)-x==0) |
| + | if(monus(Math.pow(y, 2),x)==0) |
return y; | |
else | |
return h3(x,y+1); | |
} | |
</code> | |
| − | <run id="60cb81bc7f132"> |
| + | <run id="60cb9310246f5"> |
h3(10,0) | |
</run> | |
Liefert 0. |