How to split number which has many digits with pow() functin? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to split number which has many digits with pow() functin?

Example: 45678 into 4 5 6 7 8

17th Nov 2020, 8:09 AM
TeaserCode
2 Answers
+ 7
Ipang , any code sample how this works? Thanks!
17th Nov 2020, 2:51 PM
Lothar
Lothar - avatar
+ 2
The pow() function can be used to generate a power of 10 divisor which yields a value less then 10 when used to divide the number. You can then proceed extracting each digit from the number sequentially, MODing the number by the multiplier, followed by dividing the divisor by ten, in a loop.
17th Nov 2020, 10:56 AM
Ipang