13)Write a JavaScript code for counting odd, even, prime numbers from 1 to100.


<title>count odd,even,prime no. bet’n 1 to 100</title>
<script language = “javascript”>
var i,flag=1,odd=0,even=0,prime=0,num=2;
while(num<=100)
{
for(i = 2;i<num;i++)
{
if((num%i)==0)
{
flag=0;
}
}
if(flag==1)
{
prime++;
}
num++;
flag=1;
}
for(i=1;i<100;i++)
{
if(i%2==0)
{
even++;
}
else
{
odd++;
}
}
document.write(“The no. of prime number between 1 to 100 are “+prime+” <br>”);
document.write(“The no. of even number between 1 to 100 are “+even+” <br>”);
document.write(“The no. of odd number between 1 to 100 are “+odd+” <br>”);
</script>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s