Ugly Number

Posted on

Screen Shot 2015-10-14 at 3.16.44 PM

Idea:

Boundary situation is easy, 0 & 1.

So when is the end? Get all factors until left 1. So num = 1 is the end.

Notice there is no sequence between the prime factors. So within each while loop for each prime factor, all the same factor can be divided out.

Advertisements

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