Skip to main content
edited title
Link
eldo
  • 84.7k
  • 6
  • 94
  • 210

Find equal elements onin a list

edited tags
Link
kglr
  • 403.4k
  • 18
  • 501
  • 959
Tweeted twitter.com/#!/StackMma/status/472554164480786432
deleted 3 characters in body
Source Link
Sigur
  • 703
  • 5
  • 18

Consider the following code to produce the sequence $x_1,\ldots,x_{n+1}$ where $x_i=11\cdots1$ ($i$ digits 1). Is there an easier way to do this?

n := 7 X := Table[Sum[10^i, {i, 0, k - 1}], {k, 1, n + 1}] R := Table[Mod[X[[k]], n], {k, 1, n + 1}] X R 

Also, the code defines the list R of remainders on division of $x_i$ by $n$. The output of R is {1, 4, 6, 5, 2, 0, 1, 4}.

I'd like to do the following: determine the indexes producing the first two equal elements of R (for example, since R[[1]]=R[[7]] I'd like to do some math with X[[1]] and X[[7]]).

Consider the following code to produce the sequence $x_1,\ldots,x_{n+1}$ where $x_i=11\cdots1$ ($i$ digits 1). Is there an easier way to do this?

n := 7 X := Table[Sum[10^i, {i, 0, k - 1}], {k, 1, n + 1}] R := Table[Mod[X[[k]], n], {k, 1, n + 1}] X R 

Also, the code defines the list R of remainders on division of $x_i$ by $n$. The output of R is {1, 4, 6, 5, 2, 0, 1, 4}.

I'd like to do the following: determine the indexes producing the first two equal elements of R (for example, since R[[1]]=R[[7]] I'd like to do some math with X[[1]] and X[[7]]).

Consider the following code to produce the sequence $x_1,\ldots,x_{n+1}$ where $x_i=11\cdots1$ ($i$ digits 1). Is there an easier way to do this?

n = 7 X = Table[Sum[10^i, {i, 0, k - 1}], {k, 1, n + 1}] R = Table[Mod[X[[k]], n], {k, 1, n + 1}] X R 

Also, the code defines the list R of remainders on division of $x_i$ by $n$. The output of R is {1, 4, 6, 5, 2, 0, 1, 4}.

I'd like to do the following: determine the indexes producing the first two equal elements of R (for example, since R[[1]]=R[[7]] I'd like to do some math with X[[1]] and X[[7]]).

Source Link
Sigur
  • 703
  • 5
  • 18
Loading