Wednesday, May 8, 2013

Factorial

Fact.Wml:-
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">

<wml>

<card id="card1" title="Title">
<p>
<a href="factorial.wmls#factrl(4)">Factorial</a><br/>
$(fact1)
</p>
</card>

</wml>


Factorial.wmls:-
extern function factrl(num)
{
if(num==0)
WMLBrowser.setVar("fact1","1");
if(num>0)
{
var i=1;
var fact=1;
while(i<=num)
{
fact=fact*i;
i++;
}
WMLBrowser.setVar("fact1",fact);
WMLBrowser.refresh();
}
}

No comments:

Post a Comment