Math Is Fun Forum

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

You are not logged in.

#1 2013-07-23 10:31:09

shahinpr
Member
Registered: 2013-07-23
Posts: 1

swap last and first digit

Hi,
Today my friend asked me a question.I couldn't find answer and i am not sure that there is a correct one. But he says there is.

Question:
Find a number that if you swap first and last digit you will get two times bigger number (example: 2*abcdef=fbcdea)

Do you have any idea?

Hints:
-number is 18 digit
-first digit is even number
-last digit is odd number
-only one of digits is zero

Offline

#2 2013-07-23 13:07:34

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

Re: swap last and first digit

Hi;

Welcome to the forum. The number is 105263157894736842.

See this link here from post #4 onward:

http://www.mathisfunforum.com/viewtopic.php?id=18524


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

#3 2013-09-06 06:37:26

Trenin
Member
Registered: 2013-09-06
Posts: 3

Re: swap last and first digit

Doesn't this violate the rules:
-first digit is even number
-last digit is odd number
Your number has 1 as the first digit (odd) and 2 as the last digit (even)

Last edited by Trenin (2013-09-06 06:37:44)

Offline

#4 2013-09-06 07:23:19

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

Re: swap last and first digit

Hi;

I had to make the assumption that the problem was incorrectly worded. What he really meant was the anna_g problem in this link:

http://www.mathisfunforum.com/viewtopic.php?id=18524

Because the problem as is worded does not have a solution that I can find.

I can find no solution to problem as worded for 2 digits to 30 digits. There probably is no solution.


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

#5 2013-09-06 08:24:56

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

Re: swap last and first digit

Hi bobbym

Have any idea how I could switch a number's first and last digit in M?


“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

#6 2013-09-06 08:30:18

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

Re: swap last and first digit

Yes, I do. I just wrote the subroutine for the 30th time. This time I will keep it.

Do you want the code to solve the above problem or do you just want to switch first and last of any number?


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

#7 2013-09-06 08:39:01

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

Re: swap last and first digit

Just the switching code.


“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

#8 2013-09-06 08:43:50

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

Re: swap last and first digit

Use 12345 as an example.

h = t = IntegerDigits[12345]
h[[1]] = t[[Length[t]]];
h[[Length[t]]] = t[[1]];

If you enter h you will output {5,2,3,4,1}


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