Find the nth Ugly Number

Problem 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. Write a program to find and print the 1500’th ugly number.   Solution Method 1 - Brute force Loop for all positive integers until ugly number count is smaller than n, if an integer is ugly than increment ugly number count. [Read More]

Find all sets of consecutive integers that add up to 1000.

There are total 8 such series: 1. Sum of 2000 numbers starting from -999 i.e. summation of numbers from -999 to 1000. (-999) + (-998) + (-997) + ….. + (-1) + 0 + 1 + 2 + ….. + 997 + 998 + 999 + 1000 = 1000 2. Sum of 400 numbers starting from -197 i.e. summation of numbers from -197 to 202. (-197) + (-196) + (-195) + …. [Read More]