#These are the first 100 terms of the sequence enumerating permutations of {1, ...,n} such that pi[i+2]-pi[i]<>2 using #Rintaro Matsuo's clever algorithm L22:=[1, 2, 5, 18, 75, 410, 2729, 20906, 181499, 1763490, 18943701, 222822578, 2847624899, 39282739034, 581701775369, 9202313110506, 154873904848803, 2762800622799362, 52071171437696453, 1033855049655584786, 21567640717569135515, 471630531427793184474, 10787660036599729160073, 257590656485400508526570, 6409633590481106885238443, 165928838963556686281573922, 4462073606461933066205164757, 124470791290376112779747519538, 3597058248632667485834774744787, 107559658152025736992729145688602, 3324154021716716493547315823808809, 106067493846954075776733869818571690, 3490771207487802026912252686947947027, 118383998479651470880820236769742970626, 4133478159186775319059453592629838113797, 148466883284989878437512550822854230352658, 5481445352420515241156476193244518840746091, 207869484082519643584315638277953840446577434, 8091183220183213363917372778202719985232289001, 323050241764467120657010255773065347194505456938, 13221792999576068893608581609111277819003990469083, 554385370502986503794555168916266730610467196696226, 23800472503925739016685725335017718230553739515026261, 1045621814306239157531002998400105114134277844808385202, 46984273203395373976792685973065952164512160007637624931, 2158255393499313903212082927942202089782466963438169674714, 101302136630144243673379759349962180810448939966301926767305, 4856256467469643118806194316437348317327977665078624121875050, 237663171083338468176574492075827020760055609684313221330990595, 11869083400376949860542615099405823676382105038378011862000897794, 604633939869611565405341657317429021725251188176329557645177520837, 31406516918059965680865664736257325402250876581953037087247238136082, 1662789419855435280756739052454658397497445151265931825280570003097275, 89699361348979440574892446493817889192025521039159505681046335507230298, 4928629924280904107832080994922335566057426522666912778759544242870854345, 275742303873016162993334148890481948831824673788763584293147151219193674090, 15702963986779303421654568828418126279784537624068264714490996152144655541899, 909968791161811244928813722709397567222660200173629169943011525490672471460386, 5364239902788108667621427972543500384364894114746779381760639028808279383217006\ 9, 3215890901233479183315421557340710488502421034040088080589515856994766501114\ 885170, 19601287371519340117524059855675019662424159242409315152064008959138575\ 0433927027571, 1214341326748801781376038576773783431300298987052461753153891889\ 5465445391667840175258, 7644627558525182737051747016269567095655162991472183359\ 23868723239500029911506139278569, 488901469639035212703367671622333782515778812\ 71616324752399689709527573463189634940751914, 317562570897301367173689690406522\ 1445090318436737641594508087377289295110807842538184903539, 2094483760235267634\ 96484652612966049608988254627878473189023412444956918612108285373570230786, 140\ 2375419394574449681768774682054018270311260450546742334406729822902063276474760\ 0273561082373, 9530025256987493374040250006293676759932753204817005327076162305\ 73962958507041523192093123367442, 657161312530847710734422116406672578004455122\ 80804520237430972959880155760676268720832291072566923, 459733904574281163031763\ 1138014707608541761322100673940031279280567722720829294882520372270882599066, 3262186049561077430859671203461303598899509668967337670883261688899051988809205\ 67977707407009470271785, 234742704178560704050312762416332420582325354769590898\ 21573129898157315769479127168228420740251323843754, 171266567813972411229514265\ 5273939929134031909042480195840681935002187467062530208325988595076366779667643 , 12666844095256357297585839335476619858807455696014416887908823386927661716819\ 9347914660149149763818214822050, 9495110493512461482308786820451754559529717820\ 355027079761838585735660179426009936706128495059056980639853013, 72125681502572\ 7357572294260281251837238410596395804683175855562141076441271756175743133290165\ 090794875594010802, 55508912517501885833797431196489916560048682883867843849203\ 020179776321202816248385146136850015061961162369460227, 43275781233412172524649\ 3333527604937926638331794777536776112809863776822179625506087804355818077578890\ 3296708656218, 3417156944586415715578495681592551007128433703442223173206904370\ 89678930171825556824207799285359472841434468685899657, 273245460497371123379702\ 6411649482206504788177313648824348914949099007894913652830897128385675933239271\ 0909447370165482, 2212284388571107165781611993332988822586696908126093820457683\ 923683280808650763134869940052161217347958161774552669114979, 18132702889831136\ 3560972910294897590507362051309178707614881846470111869402927307791366115987082\ 843296802375330313426157570, 15043641122551564832155561964341562550972591977552\ 582409291794263161519626430072434826851444029441515121925219631284878700997, 12\ 6313277105471352853895166843326663384539623605940941642686493927254537416123567\ 2967260108146387229460426767860563598204978706, 1073220480074690721116074216734\ 8951865313238032711291940915409154882644905975803652106265538124589038200590785\ 4388739714407522267, 9225980862978651208291242765017939329917153925886089277529\ 025063157113452242647410138542971091447518913943130716629500184254706138, 80234\ 4594534140331912900342615002524661600232483097644590336716240194631600796573504\ 597187117887737839386684503956405150462227965961, 70579175424187847891040247561\ 3313232132501525216055384061439164631649023170887000729708910290006256126538365\ 90864788730555985725652714, 627918506631090181190847979168151967533059949071792\ 1523160316656244129334919069653277608102617553182326600305914768350684433129274\ 225771, 56491887492506976678554382577585964077194353568860790462957149143898089\ 5104124411727826803383565656241253186636929325302444720459068496418, 5138912815\ 4778426270140512061075322234745305126912641920823441051434477711367808962025452\ 150138809006180882927947999334598941649993576157653, 47261360069328298417566566\ 9299487304627664419662199914968311159163868053971264779489843172992828191998853\ 7391030220428397116561515931919558706, 4393792682558161571191922210368734576972\ 1610668672366900683153714376544368524131052316173440453283552951593936497207358\ 0995070968590507436314131, 4128772637093256056090698099403015764855721204802062\ 5920566887920069905703189387645355240248179203775175864598626859102661684049092\ 740301032665882, 39210391903884821963223307296577934702040857667821522712673315\ 9786664206027292369208031212422002581778357014976075226813212356559018744018132\ 9029801, 3762980676930963767770297409823296765640072779943660900104000895954918\ 0970324360009032226709719397888370598109403752266207751796016136390120935247479\ 4, 3648935325610543846384023685972664616379518835303343131979213251492645532666\ 0970985349328538748643820298258108017808889877258332370399437910549076069075, 3574847082837687529192720842429883917430673050375454517296072722708239566193643\ 383792330256656932340917108812855344860207863363627353489787835355727388930, 35\ 3802251149664242181867270846906004401652844183567049302338486341824190709918438\ 731811536316537559475463328660733114616834105078218301711797498030562101765, 35\ 3696807669090760425852370145693959586525038035759690290258171395181600510368598\ 90566016536490984980819091354498485019406515518825054504757481070295554329874]: # # # --------------------------------- # # # # This took, 1418.079, seconds.