<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/nth-character-in-concatenated-decimal-string-zfwlzhduw" -->

---
title: Nth Character in Concatenated Decimal String | daily.dev
description: Finding the nth character in the infinite string '123456789101112...' can be done without ever building that string. Numbers are grouped by digit length: 9...
canonical: https://daily.dev/posts/nth-character-in-concatenated-decimal-string-zfwlzhduw
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Nth Character in Concatenated Decimal String | daily.dev
og:description: Finding the nth character in the infinite string '123456789101112...' can be done without ever building that string. Numbers are grouped by digit length: 9...
og:url: https://daily.dev/posts/nth-character-in-concatenated-decimal-string-zfwlzhduw
og:image: https://api.daily.dev/og/posts/ZFWLZhduw.png
og:image:alt: Nth Character in Concatenated Decimal String
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Nth Character in Concatenated Decimal String

**[C\# Corner](https://daily.dev/sources/csharpcorner)** · 8 min read · 0 upvotes · 0 comments

## Summary

Finding the nth character in the infinite string '123456789101112...' can be done without ever building that string. Numbers are grouped by digit length: 9 one-digit numbers give 9 characters, 90 two-digit numbers give 180, 900 three-digit numbers give 2700, and so on. A loop subtracts each full range's character count from n until the right digit-length range is found, then `start + (N - 1) / digits` locates the number and `(N - 1) % digits` locates the digit inside it. The Java solution runs in O(log n) time with O(1) space.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.c-sharpcorner.com/article/nth-character-in-concatenated-decimal-string>

## Questions this post answers

### How do you find the nth character in the infinite string formed by concatenating 1, 2, 3, 4...?

Group numbers by digit length and skip whole ranges instead of building the string. One-digit numbers (1-9) contribute 9 characters, two-digit numbers (10-99) contribute 180, and so on, each range being 10 times larger. Subtract each range's total until the remaining count fits, then compute number = start + (N-1)/digits and index = (N-1)%digits to get the exact digit.

_daily.dev surfaces algorithm walkthroughs like this one for developers sharpening coding-interview skills._

### What is the time and space complexity of finding the nth digit of the infinite digit sequence without generating it?

The algorithm runs in O(log n) time and O(1) auxiliary space. It loops only once per digit-length range (1 digit, 2 digits, 3 digits, etc.), so the number of iterations grows logarithmically with n, and no string of the full sequence is ever stored in memory.

_Developers comparing algorithm efficiency trade-offs can track approaches like this via daily.dev._

## Similar posts on daily.dev

- [Computing the Padovan Sequnce in Java](https://daily.dev/posts/computing-the-padovan-sequnce-in-java-kz80lh7jr) · Baeldung · 1 upvotes · 0 comments
- [Count Substrings with More 1's than 0's](https://daily.dev/posts/count-substrings-with-more-1-s-than-0-s-k63z1kpmf) · C\# Corner · 0 upvotes · 0 comments
- [Implement the FizzBuzz Puzzle in Java](https://daily.dev/posts/implement-the-fizzbuzz-puzzle-in-java-5xu9ywnko) · Baeldung · 1 upvotes · 0 comments

---

Tags: [#java](https://daily.dev/tags/java), [#algorithms](https://daily.dev/tags/algorithms)

[View this post on daily.dev](https://daily.dev/posts/nth-character-in-concatenated-decimal-string-zfwlzhduw)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Nth Character in Concatenated Decimal String","url":"https://daily.dev/posts/nth-character-in-concatenated-decimal-string-zfwlzhduw","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/nth-character-in-concatenated-decimal-string-zfwlzhduw"},"datePublished":"2026-10-28T07:59:30.305Z","dateModified":"2026-10-28T08:08:15.834Z","description":"Finding the nth character in the infinite string '123456789101112...' can be done without ever building that string. Numbers are grouped by digit length: 9...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/948d4bf03599c17b76600e6a813c4b62?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/948d4bf03599c17b76600e6a813c4b62?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"C# Corner","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"C# Corner","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/ada2d584df6241748fc4e71878dc70a3","url":"https://daily.dev/sources/csharpcorner"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/nth-character-in-concatenated-decimal-string-zfwlzhduw","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"java,algorithms","timeRequired":"PT8M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"C# Corner","item":"https://daily.dev/sources/csharpcorner"},{"@type":"ListItem","position":3,"name":"Nth Character in Concatenated Decimal String"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/nth-character-in-concatenated-decimal-string-zfwlzhduw#faq","mainEntity":[{"@type":"Question","name":"How do you find the nth character in the infinite string formed by concatenating 1, 2, 3, 4...?","acceptedAnswer":{"@type":"Answer","text":"Group numbers by digit length and skip whole ranges instead of building the string. One-digit numbers (1-9) contribute 9 characters, two-digit numbers (10-99) contribute 180, and so on, each range being 10 times larger. Subtract each range's total until the remaining count fits, then compute number = start + (N-1)/digits and index = (N-1)%digits to get the exact digit. daily.dev surfaces algorithm walkthroughs like this one for developers sharpening coding-interview skills."}},{"@type":"Question","name":"What is the time and space complexity of finding the nth digit of the infinite digit sequence without generating it?","acceptedAnswer":{"@type":"Answer","text":"The algorithm runs in O(log n) time and O(1) auxiliary space. It loops only once per digit-length range (1 digit, 2 digits, 3 digits, etc.), so the number of iterations grows logarithmically with n, and no string of the full sequence is ever stored in memory. Developers comparing algorithm efficiency trade-offs can track approaches like this via daily.dev."}}]}
```

