# How to prove that an equation can be divided by any n?

I'm new to Mathematica and came across with the problem. I can't prove that (for example) 2*n is always even no matter what n is. I could do this If I had some range. (Would use Table, Mod and Length function) But I don't know what to use in this situation. And one more question please. Is it possible to have a list (1,3,5,7) and get the indexes of prime numbers (3,4) and both numbers and indexes together ({3,5}, {4, 7}). Thanks in advance.

• 3 is also a prime number. – march Apr 13 '16 at 20:17
• For the first, Simplify[Mod[2*n + 2, 2], n \[Element] Integers] evaluates to 0, which means that 2*n + 2 is even. Alternatively, EvenQ[2 # + 2] & /@ Range[-20, 20, 2] yields a list of True's, and you can extend the list to any maximum or minimum integer you want. – march Apr 13 '16 at 20:19

For the first, here are two options (the second from BlacKow):

Simplify[Mod[2*n + 2, 2], n ∈ Integers]
Simplify[Divisible[2*n + 2, 2], n \[Element] Integers]
(* 0 *)
(* True *)


means that 2*n + 2 is always even. Alternatively, checking a "few" cases:

EvenQ[2 # + 2] & /@ Range[-200, 200, 2] // And @@ # &
(* True *)


For the second question (and for future reference: asking two questions in one post that are not closely related is considered against the rules):

Sample list:

list = Range[1, 20, 2]
{1, 3, 5, 7, 9, 11, 13, 15, 17, 19}


Selecting:

Select[Transpose[{Range[Length@list], list}], PrimeQ[#[]] &]
(* {{2, 3}, {3, 5}, {4, 7}, {6, 11}, {7, 13}, {9, 17}, {10, 19}} *)

• or you can use Divisible instead of Mod – BlacKow Apr 13 '16 at 20:34
• @BlacKow. Oh yeah, that's better! – march Apr 13 '16 at 20:35
• is 2n not a more complete and simpler test that 2n+2? – RunnyKine Apr 13 '16 at 21:42
• FullSimplify[Mod[2 n, 2] == 0, n \[Element] Integers] returns True – bill s Apr 13 '16 at 22:48

Another method for the second question uses the Position function along with the _? (PatternTest) construct:

list = Range[1, 20, 2]
Transpose[{Flatten[Position[list, _?PrimeQ]], Select[list, PrimeQ]}]
(* {{2, 3}, {3, 5}, {4, 7}, {6, 11}, {7, 13}, {9, 17}, {10, 19}} *)

• Aren't you testing for being prime twice? What about Transpose@{#, list[[#]]} &@Flatten[Position[list, _?PrimeQ]] – BlacKow Apr 13 '16 at 22:04