Hertz Posted December 3, 2009 Report Posted December 3, 2009 Se dau primii 2 termeni a unei secvente fiind 1 si trebuie sa insumezi toti termeni anteriori ,apoi sa ridici suma la ptrat pentru a genera urmatorul termen.Secventa va arata astfel :1 1 4 36 ... secventa actuala a termenilor la patrat1 1 2 6 ... termeniiCare e suma cifrelor celui de-al 10-lea termen din secventa anterioara? Quote
begood Posted December 3, 2009 Report Posted December 3, 2009 #include<iostream.h>unsigned long v[9];int sumac(unsigned long a){int n=0;while(a){n+=a%10;a/=10;}return n;}void main() { v[0]=1;v[1]=1; //v[2]=(v[0]+v[1])^2; for(int i=2;i<=9;i++) { for(int j=0;j<i;j++) v[i]=v[i]+v[j]; v[i]=v[i]*v[i]; } cout<<sumac(v[9]); }38//al zecelea termen fiind : 1227672452 Quote
begood Posted December 3, 2009 Report Posted December 3, 2009 kkt ... e gresit ca merge pe 16 biti si e mai lunga de 10 cifre....compilati voi pe ceva mai bun de borlandc3.1 4:436:91764:183261636:272829760580:47704033252:26763197476:501227672452:38haha wolframalpha ftw 165506647324519964198468195444439180017513152706377484976912705487864128102426408447950441478478159989636faceti voi suma !LE: hahahahah http://www.wolframalpha.com/input/?i=sum+of+digits+165506647324519964198468195444439180017513152706377484976912705487864128102426408447950441478478159989636rezultat : 495 Quote