Sum Skipping Multiples of 7
Updated
Problem statement
Given a positive integer n, return the sum of all integers from 1 to n, skipping every number that is a multiple of 7.
Both 1 and n are part of the range.
Function
sumSkippingMultiplesOfSeven(n: int) → longExamples
Example 1
n = 10return = 48The numbers from 1 to 10 add up to 55. The only multiple of 7 in that range is 7, so the answer is 55 - 7 = 48.
Example 2
n = 6return = 21No number from 1 to 6 is a multiple of 7, so all of them are added: 1 + 2 + 3 + 4 + 5 + 6 = 21.
Example 3
n = 14return = 84The numbers from 1 to 14 add up to 105. Skipping 7 and 14 removes 21, so the answer is 105 - 21 = 84.
Constraints
1 <= n <= 10^9
More Bank of America Online Assessment questions
- Return Exact Cash Register ChangeOA · Seen Aug 2026
- 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
- Letter Pattern SumOA · Seen Sep 2022
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