#money is an integer value GreedyChange=function(money){ coins=c(1,2,5,10,50) # coin vector change=NULL #used coins. It is a vector while(money>0){ coin=max(coins[coins<=money]) #coins[coins<=money] select the values in coins lower than or equal to money change=c(change,coin) money=money-coin } return(change) } #money is integer value and coins a integer vector RecursiveChange=function(money,coins){ if (money==0) return(0) MinNumCoins=.Machine$integer.max for (coin_i in coins){ #coin_i slides the coins elements if (money>=coin_i){ NumCoins=RecursiveChange(money-coin_i,coins) if (NumCoins+1=coin_i){ Res=RecursiveChangeMod(money-coin_i,coins) if (Res[[1]]+1=coin_i){ if ((MinNumCoins[m-coin_i]+1)