Question bank › Math
Dsa Math Easy

Integer Factorization Count

You are given a positive integer N. Your task is to determine how many distinct ways you can express N as a sum of one or more positive integers. For example, if N is 5, the distinct sums can be: 5, 4+1, 3+2, 3+1+1, 2+2+1, 2+1+1+1, 1+1+1+1+1 (total of 7). Please write a program that reads the integer N and outputs the count of distinct ways to sum to N. Input Format: - A single integer N (1 <= N <= 30) Output Format: - A single integer representing the count of distinct sums. Example: Input: 5 Output: 7

Key concepts

mathcombinatorics

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.