#OK to post homework #Zidong Zhang, 4/11/2021, Assignment 21 with(Bits): #IntegterToVec(k,n), VecToInteger(v,n):that inputs an integer k in [1,2^n] (and n) and outputs the vector of length n that corresponds to the binary represenation of k-1 (written as a list) (with zeros padded at the front to make it of length n, if necessary) and its inverse procedure VecToInteger(v,n) #when I did some search, I found a very good function that can do exacly what you ask in this funciton it's Bits[Split(k,bits=n)]: IntegerToVec:= proc(k,n) local S: Split(k-1, bits=n): end: VecToInteger:=proc(v,n) local num , i: num:=0: for i from 1 to nops(v) do if v[i]<>0 then num:= num+2^(i-1): fi: od: num: end: