Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#26 2012-05-05 22:48:05

anonimnystefy
Real Member
From: Harlan's World
Registered: 2011-05-23
Posts: 16,049

Re: sum of digit

I think gAr is summing all digits in the ones place then in the tens place and so on.

Without repetiton is neccesary because if it wasn't mentioned you could have the numbers like d1,d1d1,and so on,included too,which would be an infinite amount of numbers by itself. Not to mention if we brought in d2.

Also,I am seeing right now that gAr's aasumption might be wrong,and that it is not only n-digit numbers that need to be summed.


“Here lies the reader who will never open this book. He is forever dead.
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.

Offline

#27 2012-05-05 23:09:22

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,810

Re: sum of digit

Hi stefy,

Yes, I see now why "without repetition" was included. Thanks.

I think we need juantheron to clear this up, and maybe to give us an example.


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#28 2012-05-05 23:16:09

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: sum of digit

Hi phrontister;

When I first looked at the problem I had a whole different idea about it too. But after seeing gAr's solution I tend to think he is correct in how he is interpreting it.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#29 2012-05-05 23:19:52

anonimnystefy
Real Member
From: Harlan's World
Registered: 2011-05-23
Posts: 16,049

Re: sum of digit

I think we should all wait for juan to explain.


“Here lies the reader who will never open this book. He is forever dead.
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.

Offline

#30 2012-05-05 23:21:57

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,810

Re: sum of digit

Ah! Light dawns!! Yes...I go with gAr's interpretation too as to what juantheron is after.

Thanks, Bobby.


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#31 2012-05-05 23:22:53

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: sum of digit

An explanation from juan would remove any doubt.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#32 2012-05-06 13:08:11

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,810

Re: sum of digit

Hi Bobby,

Looks like when summing M's Permutation results this way, numbers with leading zeros are seen as valid (even though the zero isn't and gets dropped), which, if you used M, would be at least one reason why my answer for 10 differs from yours as I omitted such numbers in my LB program.

So the sum of the permutations of 306 in M is 1998, but in mine is 1899 because I treated 36 and 63 as invalid. But my treatment may be incorrect.

Re your answer 22175999997782400 for 10 in post #18. I got a different answer, but maybe my code is wrong:

I thought that the code would pick up all the permutations for numbers with digits 0 to 9, including numbers with a leading zero, because I'm using the same code as for 'My M' above, which gave the correct result.

Last edited by phrontister (2012-05-07 10:31:22)


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#33 2012-05-06 17:02:40

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: sum of digit

Hi phrontister;

FromDigits will not treat a leading zero as a legitimate digit:

FromDigits[{0,1,2,3}] returns 123 a 3 digit number.

I got a different answer,

Your answer for 0,1,2,3,4,5,6,7,8,9 is correct.

For a special reason so is mine. gAr's formula holds for special cases too. Supposing we had a number system 1,2,3,4,5,6,7,8,9,A  where A had a value of 10 but was a single digit. Makes me dizzy just thinking about it. Sort of like Hexadecimal. That is what my answer is for.

By the way that is very impressive what you did with M there. You understand mapping, Total and a few other commands. Excellent!


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#34 2012-05-07 01:31:47

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,810

Re: sum of digit

Hi Bobby,

Yes, learning a few things here and there...as the need arises from puzzles that I want to try in M. smile

Had my head down in the help files for quite some time before I worked this one out.


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#35 2012-05-07 01:34:16

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: sum of digit

If you understand that much then I would say you have everything you need.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#36 2012-05-07 04:32:54

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,810

Re: sum of digit

Hi Bobby,

I'm on the way...'on a slow boat to China'. Muuuch to learn yet, as the little people would say.

But my treatment may be incorrect.

I just downloaded a nice (for BASIC) permutations program from an LB forum. It gives the same result as M, and leading zeros print in the output (as do M's before FromDigits removes them).

I altered the program to ask for the initial number string and to display the sum of the string's permutations.

Unfortunately it only handles numbers below 9 digits long. The program shuts down after that due to low memory...probably because of dimming all permutations.

Last edited by phrontister (2012-05-07 10:34:32)


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#37 2012-05-07 04:38:07

anonimnystefy
Real Member
From: Harlan's World
Registered: 2011-05-23
Posts: 16,049

Re: sum of digit

Arghhhh...you guys are such good programmers. I wish I could be somewhat better at programming.


“Here lies the reader who will never open this book. He is forever dead.
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.

Offline

#38 2012-05-07 05:46:37

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: sum of digit

I'm on the way...'on a slow boat to China'.

Those boats sure are slow.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#39 2012-05-07 06:05:37

anonimnystefy
Real Member
From: Harlan's World
Registered: 2011-05-23
Posts: 16,049

Re: sum of digit

Hi m

What programming languages did you say you know?


“Here lies the reader who will never open this book. He is forever dead.
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.

Offline

#40 2012-05-07 06:06:21

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: sum of digit

You mean which ones I forgot.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#41 2012-05-07 06:08:40

anonimnystefy
Real Member
From: Harlan's World
Registered: 2011-05-23
Posts: 16,049

Re: sum of digit

Proceed.


“Here lies the reader who will never open this book. He is forever dead.
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.

Offline

#42 2012-05-07 06:18:53

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: sum of digit

At one time Forth, 3 or 4 Basics of course, Lisp, 2 or 3 Assembly languages, C++ and a smattering of others.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#43 2012-05-07 07:36:27

anonimnystefy
Real Member
From: Harlan's World
Registered: 2011-05-23
Posts: 16,049

Re: sum of digit

Have you ever heard of the pl called Brainf*ck? It uses only 8 symbols for its syntax.


“Here lies the reader who will never open this book. He is forever dead.
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.

Offline

#44 2012-05-07 08:20:55

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: sum of digit

Yes, I thought is was just an oddity.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#45 2012-05-07 08:23:36

anonimnystefy
Real Member
From: Harlan's World
Registered: 2011-05-23
Posts: 16,049

Re: sum of digit

There is an eben stranger one. It is called Whitespace. I would like to get a compiler for it,but cannot manage to install one properly.


“Here lies the reader who will never open this book. He is forever dead.
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.

Offline

#46 2012-05-07 08:29:36

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: sum of digit

Why do you want one?


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#47 2012-05-07 08:35:27

anonimnystefy
Real Member
From: Harlan's World
Registered: 2011-05-23
Posts: 16,049

Re: sum of digit

I think it would be fun to program in Whitespace.


“Here lies the reader who will never open this book. He is forever dead.
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.

Offline

#48 2012-05-07 08:40:19

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: sum of digit

Yes, but is it useful? Can you do anything with it that justifies the time spent?


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#49 2012-05-07 22:19:29

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,810

Re: sum of digit

Hi Bobby,

Learnt a bit more M tonight. I used Select to enable me to sum just the numbers without a leading zero, which for 0,1,2,3,4,5,6,7,8,9 totalled 17942399998387200.

Happily ( smile ) , that is the same answer I got back in post #19, which is something I wanted to test as a proof for the correctness of the formula I came up with back then.

Select took a while to unearth. Before that I'd tried Cases (with Except and some patterns), Delete and some others I've now forgotten, but I couldn't get anything to work. Other functions will probably work somehow, but I tried lots of options and couldn't find the 'somehow' until Select.


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#50 2012-05-07 22:24:16

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: sum of digit

Hi phrontister;

Very good! You learned a little bit of the lambda calculus.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

Board footer

Powered by FluxBB