Polite Numbers - Calculate all the ways such that a number can be written as sum of 2 or more consecutive numbers

Problem Write a program that calculates all the ways that a number can be written as the sum of two or more consecutive numbers and generate those sets. Background  In number theory, a polite number is a positive integer that can be written as the sum of two or more consecutive positive integers. The first few polite numbers are 3, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17,… [Read More]

Find next higher number using exact same digits

Problem Given a number X find the number Y which is next higher number than X using the exact same digits as in X. Example For example: given 38276 return 38627 Solution Method 1 - Brute force The brute-force method is to generate the numbers with all digit permutations and consider all the higher numbers than the given number and return the minimum number from those higher numbers. [Read More]