Похожие чаты

I can't think of the proper mathematical term for this

so it's making it hard to search. If I want to take a number and determine whether it's in the 1's, 10's, 100's, etc. how would I do that? For instance:
4 -> 1
6 -> 1
17 -> 10
32 -> 10
99 -> 10
100 -> 100
872 -> 100
999 -> 100
I'm hoping there's a way to do this mathematically without using a loop or hash map.

11 ответов

26 просмотров

Finding the exponent?

Just divide by 10 until 0 and increment a counter

Watzon-🍉🇵🇸 Автор вопроса
Thomas
Just divide by 10 until 0 and increment a counter

Right, I know of that way, but I'm hoping there's a way to do it and avoid using a loop

Watzon-🍉🇵🇸 Автор вопроса
Simen
Go for readability over speed.

This is for leetcode, so I don't really care about readability

log with base 10

well this can be solved using log with base 10 10 ^ (int(log x))

Fan / Ac
well this can be solved using log with base 10 10 ...

Jesus how many ways are you going to say the same thing

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта