FastPrepSum Skipping Multiples of 5 or 7
Problems/Sum Skipping Multiples of 5 or 7

Sum Skipping Multiples of 5 or 7

Bank of America logoBank of America● EasyINTERNNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported from a video interview step for a Bank of America intern role that had coding tasks. The task was to add up the numbers from 1 to n but leave out every number that 5 or 7 divides evenly, and it came with one worked example.

The original reads several values of n and prints each answer; here you get one n and return the sum. The report gives no limit on n, so we set n up to one billion, which needs a 64-bit answer.

Our version is about 95% the same as the reported question.

Given a positive integer n, return the sum of all integers from 1 to n, skipping every number that is divisible by 5 or by 7.

Both 1 and n are part of the range.

Function

filteredIntegerSum(n: int) → long

Examples

Example 1

n = 10return = 33

The included values are 1, 2, 3, 4, 6, 8, 9, whose sum is 33.

Example 2

n = 1return = 1

The range holds only 1, which is not divisible by 5 or 7, so the sum is 1.

Example 3

n = 35return = 420

Start from the sum 1 + ... + 35 = 630. Remove the multiples of 5 and 7, then add 35 back once because it was removed twice, leaving 420.

Constraints

  • 1 <= n <= 10^9
  • The answer fits in a signed 64-bit integer.

More Bank of America Online Assessment questions

  • Return Exact Cash Register ChangeOA · Seen Aug 2026
  • Sum Skipping Multiples of 7OA · Seen Nov 2025
  • Wildcard Substring MatchOA · Seen Nov 2025
  • Maximum String BeautyOA · Seen Sep 2024
  • Merge Point of Two Linked ListsOA · Seen Oct 2023
  • Remove Duplicates from a ListOA · Seen Oct 2023
  • Pairs with Target Sum in a Sorted ArrayOA · Seen Oct 2023
  • Count Level-Order Traversals of a TreeOA · Seen Sep 2023
  • Count Set BitsOA · Seen Sep 2023
  • Count Pairs with Sum KOA · Seen Jun 2023

Similar questions at other companies

  • Summarize Taxi Drivers and RidesBoston Consulting Group · OABoston Consulting Group interview questions
  • Total Cost Against the Lowest Earlier PricePayPal · OAPayPal interview questions
  • Count Valid Square PairsAuxoAI · OA
  • Counting Cows by Their LegsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Server InvestmentRippling · OARippling interview questions
  • Basic Item DiscountsPalantir · OAPalantir interview questions
  • Identification Number Check DigitAbridge · OAAbridge interview questions
  • Count Substrings With Identical CharactersVirtu Financial · OAVirtu Financial interview questions
  • Next Pascal Row CoefficientIntuit · OAIntuit interview questions
  • Digit-Sum Sequence Join PointOpenAI · OAOpenAI interview questions

Interview reports that mention this question

  • Bank of America OA · December 2020
  • Bank of America OA · October 2021
  • Bank of America OA · September 2022
  • Bank of America OA · October 2023
  • Bank of America OA · September 2024

Bank of America interview experiences

  • Bank of America OA · April 2014
All Bank of America interview questionsSee Bank of America hiring insights
Saved
class Solution {
    public long filteredIntegerSum(int n) {
        // write your code here
    }
}
Checking account…