❔ help with an exercise
I've encountered a weird problem that idk how to fix. Say we've got a string "31131123521" how do i make it so each number of the string is multiplied by one another so the string we have got will be equal to 3 * 1 * 1 * 3 * 1 * 1 * 2 * 3 * 5 * 2 * 1 (this is equal to 540). I have trouble finding a patter or solution to this when it seems very simple. Given a string i just want to multiply each number inside of it
25 Replies
First, you'll need to get an array of numbers from this string
Use the fact that a string already is an array of chars
And that a method
char.GetNumericValue()
method exists
You'll need to do the multiplications in a loop
And keep the result outside of the loopmind writing some quick code for this ; ; ?
heres the structure
i dont know how to like, i even tried using chatGPT for this and still nothing
i dont know in what pattern to multiply the numbers
*
a huge number in the millions always comes up
There's no pattern
That's how you multiply
when in fact the answer is 540
i know
okay can yall get my code and do it then
Nope
Not doing your homework for you
We can tell how to do it
You could really google what @Angius just told
How to make a string into char array?
thats not my problem
Then?
i know to convert chars into ints and such. the problem is when i try doing it with code the answer comes up as smth ludicrous in the millions. keep in mind this is the string "31131123521"
Show the code, then
when in fact the answer to 3 * 1 * 1 * 3 * 1 * 1 * 2 * 3 * 5 * 2 * 1 is 540
Show your code that converts the string into an array of ints
Yes
If the logic for how you're multiplying is flawed then it'd obv show huge number
it is flawed
thats what im asking for ; ;
the logic itself
Well, show the code
sec
Show us what you've done, for us to understand where u went wrong
sorry i had to do smth
Seems to work just fine
nevermind it was my mistake
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.