What is the best way to find the period of a (repeating) list in Mathematica?

前端 未结 9 1376
没有蜡笔的小新
没有蜡笔的小新 2021-01-01 15:12

What is the best way to find the period in a repeating list?

For example:

a = {4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2}

has repeat

9条回答
  •  天命终不由人
    2021-01-01 16:11

    #include 
    #include 
    using namespace std;
    
    
    int period(vector v)
    {
        int p=0; // period 0
    
        for(int i=p+1; i v3{1,2,3,1,2,3,1,2,3};
        cout<<"Period is :\t"< v0{1,2,3,1,2,3,1,9,6};
        cout<<"Period is :\t"< v1{1,2,1,1,7,1,2,1,1,7,1,2,1,1};
        cout<<"Period is :\t"<

提交回复
热议问题