FastPrepConsecutive Sum (Financial Engineer Intern)
Problems/Consecutive Sum (Financial Engineer Intern)

Consecutive Sum (Financial Engineer Intern)

Bloomberg LP logoBloomberg LP● MediumINTERNOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Given a long integer, num, find the number of ways to represent it as a sum of two or more consecutive positive integers. For example:

  • If num = 15, then there are three such ways: (1 + 2 + 3 + 4 + 5) = (4 + 5 + 6) = (7 + 8) = 15.
  • If num = 2, then there are zero such ways.

Complete the consecutive function in the editor below. It has one parameter: a long integer named num. The function must return an integer denoting the number of ways to represent num as a sum of two or more consecutive positive integers.

Input Format

Locked stub code in the editor reads a long integer denoting num from stdin and passes it to the function.

  • 1 ≤ num ≤ 10^12

Output Format

Return an integer denoting the number of ways to represent num as a sum of two or more consecutive positive integers.

Function

consecutive(num: long) → int

Examples

Example 1

num = 15return = 3

Might or might not be an accurate explanation :)

There are three ways to represent num = 15 as a sum of two or more consecutive positive integers:

  • (1 + 2 + 3 + 4 + 5)
  • (4 + 5 + 6)
  • (7 + 8)

Therefore, the function returns 3.

Constraints

  • 1 ≤ num ≤ 10^12

More Bloomberg LP interview questions

  • Count Distinct Arrays After Decrement OperationsOA · Seen Nov 2026
  • Minimum BeautyOA · Seen Nov 2026
  • Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
  • Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
  • Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026

Similar questions at other companies

  • Polynomial CoefficientsShopify · OAShopify interview questions
  • Basic Calculator IITypeSafe AI · OA
  • Last Object to Fall Off the TableConfluent · OAConfluent interview questions
  • Last Object Exit TimeIBM · OAIBM interview questions
  • Count Prime Values in SubtreesVisa · OAVisa interview questions
  • Minimum Rounds to Complete All TasksInfosys · OAInfosys interview questions
  • Server Upgrade PlanningWells Fargo · OAWells Fargo interview questions
  • Capping Portfolio WeightsCapstone Investment Advisors · OA
  • Gaussian Naive Bayes Classifier (Machine Learning OA)Pinterest · OAPinterest interview questions
  • Bold Play to Reach a GoalSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions

Bloomberg LP interview experiences

  • Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
  • Bloomberg SWE Intern Interview Questions: 68 Questions
  • Bloomberg Interview Questions, Level Not Reported: 65 Questions
  • Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
  • Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
  • Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public int consecutive(long num) {
      // write your code here
    }

}
Checking account…