Tuesday, April 19, 2016

find the ways to make specific number with dice

this problem is about hexanacci number

               long a = 0,b= 0,c= 0,d= 0,e= 0,f=1, t = 0;
  
  for (int i = 1; i <= n; i++) {
   t = a+b+c+d+e+f;   
   a=b;
   b=c;
   c=d;   
   d=e;
   e=f;
   f=t;
  }
  return t+"";


Hexanacci numbers: a(n+1) = a(n)+...+a(n-5) with a(0)=...=a(4)=0, a(5)=1. 

No comments:

Post a Comment