Skip to main content
1 of 3
user1066
  • 22.7k
  • 3
  • 36
  • 59

(1)

(NestList[#+1&,{0,2},2]//Flatten//Reverse)

(* {4, 2, 3, 1, 2, 0} *) 

(2)

(NestList[#+1&,{0,2},3]//Flatten//Reverse)

(*{5, 3, 4, 2, 3, 1, 2, 0} *) 

(3)

(NestList[#+1&,{0,2},#]//Flatten//Reverse)&/@Range[2,10]

(*
{
 {4, 2, 3, 1, 2, 0}, 
 {5, 3, 4, 2, 3, 1, 2, 0}, 
 {6, 4, 5, 3, 4, 2, 3, 1, 2, 0}, 
 {7, 5, 6, 4, 5, 3, 4, 2, 3, 1, 2, 0}, 
 {8, 6, 7, 5, 6, 4, 5, 3, 4, 2, 3, 1, 2, 0}, 
 {9, 7, 8, 6, 7, 5, 6, 4, 5, 3, 4, 2, 3, 1, 2, 0}, 
 {10, 8, 9, 7, 8, 6, 7, 5, 6, 4, 5, 3, 4, 2, 3, 1, 2, 0}, 
 {11, 9, 10, 8, 9, 7, 8, 6, 7, 5, 6, 4, 5, 3, 4, 2, 3, 1, 2, 0}, 
 {12, 10, 11, 9, 10, 8, 9, 7, 8, 6, 7, 5, 6, 4, 5, 3, 4, 2, 3, 1, 2, 0}
}
*)
user1066
  • 22.7k
  • 3
  • 36
  • 59