Tuesday, July 22, 2008

C program to find Ugly numbers

Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence

1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, ...

shows the first 11 ugly numbers. By convention, 1 is included.

Here is the program to find nth Ugly number



main()
{
int i, j, n, count = 0;
printf("Enter which ugly number you want\n");
scanf("%d", &n);
int b[n];
for(i = 1; count < n; i++)
{
j = i;
while(j % 2 == 0)
{
j = j / 2;
}
while(j % 3 == 0)
{
j = j /3;
}
while(j % 5 == 0)
{
j = j / 5;
}
if(j == 1)
{
b[count] = i;
count++;
}
}
printf("nth ugly number is %d", b[n-1]);
getch();
}

Thursday, July 17, 2008

Get rid of connection timedout error (110) with yum in fedora 9

To get rid of this error first check yum.conf, where your internet connection details have been set. Suppose if u r using proxy then edit yum.conf and add below line.
http_proxy="http://Proxy IP:port number

But you should be a root user to edit the file yum.conf

Then save it. Now, you don't have the problem sated above.

Saturday, April 12, 2008

How to troubleshoot 500 internal sever while running perl scripts

I wasted my time in solving 500 internal server error in Apache. I don't know why it was happening. Finally I recovered from this error. What I did is just i changed the first line in the script to
#!/perl/bin/perl -w

Thursday, March 27, 2008

How to increase the Memory for JVM

Some times in your java programming the memory for JVM should be increased to avoid 'out of memory error'.

To do that we should specify the minimum and maximum memory for JVM by using the following command.

1. Go to Start button--> run command--> type cmd
2. Enter the path of the program to run
3. Give the command: java -Xms64m -Xmx256m classname of your program

In the above command -Xms is the minimum memory and -Xmx is the maximum memory. 64m is 64MB and 256m is 256MB.

By default the memory occupied by JVM is 64MB