Counting Ones
CodeChefOpen on judge ↗
CodePlex - Pramana 2018 Problem description. This program is a fun math problem! Consider a function f (n) that takes a positive integer n and returns the number of 1's in the decimal representation of all the integers from 0 to n, inclusive. For example, f(13) = 6, for the numbers 1, 10, 11 (twice, for two 1s), 12 and 13. Notice that f (1) = 1. Your task is to write a program that calculates f
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start