[Date Index]
[Thread Index]
[Author Index]
Re: Numbers and their reversals
*To*: mathgroup at smc.vnet.net
*Subject*: [mg53699] Re: [mg53687] Numbers and their reversals
*From*: DrBob <drbob at bigfoot.com>
*Date*: Mon, 24 Jan 2005 03:37:20 -0500 (EST)
*References*: <200501230702.CAA11076@smc.vnet.net>
*Reply-to*: drbob at bigfoot.com
*Sender*: owner-wri-mathgroup at wolfram.com
Here's a modification to allow palindromes optionally, and an "explain" routine that shows how a number factors in this way (if it does):
Clear[omariQ,omariD,explain]
reverse=FromDigits@Reverse@IntegerDigits@#&;
commonDivisors=Rest@Divisors@GCD[#,reverse@#]&;
omariQ[n_Integer,k_Integer,
palindromes_:False]:=(palindromes||n!=reverse@n)&&IntegerQ[n/k]&&
k reverse[n/k]\[Equal]reverse@n
omariD[n_Integer,palindromes_:False]:=Select[commonDivisors@n,omariQ[n,#,\
palindromes]&]
omariQ[n_Integer,palindromes_:False]:=Length@omariD[n,palindromes]>0
explain[n_,palindromes_:
False]/;omariQ[n,palindromes]:=Module[{o=omariD[n,palindromes],tmp},
Print["The omari divisors of n = ",n," are o = ",o];
Print["n/o : ",tmp=n/o];
Print["reverse/@(n/o) : ",tmp=reverse/@tmp];
Print["o reverse/@(n/o) : ",tmp=o tmp];
]
explain[__]:=Null
explain[17*242]
(no output)
explain[17*242, True]
"The omari divisors of n = "4114" are o = "{17, 34, 187, 374, 2057, 4114}
"n/o : "{242, 121, 22, 11, 2, 1}
"reverse/@(n/o) : "{242, 121, 22, 11, 2, 1}
"o reverse/@(n/o) : "{4114, 4114, 4114, 4114, 4114, 4114}
explain[627172]
"The omari divisors of n = "627172" are o = "{91}
"n/o : "{6892}
"reverse/@(n/o) : "{2986}
"o reverse/@(n/o) : "{271726}
Bobby
On Sun, 23 Jan 2005 02:02:17 -0500 (EST), F. omari <towtoo2002 at yahoo.com> wrote:
>
> i want to investigate the following two equations:
> a * const = z
> a_Reversed * const = z_Reversed
> where a, z, and their reversed form and const are all positive integers
> ie such that:
> 2684 * 17 = 45628
> 4862 * 17 = 82654
> 2986 * 91 = 271726
> 6892 * 91 = 627172
> it happened that many multipliers of 91 have such a property.
> while the multipliers of 17 have only 5 cases in the interval of 1 to 3000
> the following code will investigate the multipliers of 17, to investigate another number just replace 17. and you may increase the interval of investigation. i am sure that my code is an old fashion one, please any other ideas about a more functional code.
> a = Table[i, {i, 1, 3000}]; zR = ""; aR = 0; z = "";
> Do[aR = ToExpression[StringReverse[ToString[a[[i]]]]];
> z = ToString[a[[i]]*17];
> zR = StringReverse[ToString[aR*17]];
> If[zR == z, Print[a[[i]]]], {i, 1, 3000}]
>
> 242
> 484
> 2442
> 2662
> 2684
> regards
>
>
>
>
>
--
DrBob at bigfoot.com
www.eclecticdreams.net
Prev by Date:
**Re: compile / optimize**
Next by Date:
**Maxima & Minima**
Previous by thread:
**Re: Numbers and their reversals**
Next by thread:
**Re: Numbers and their reversals**
| |