Jump to content
Hertz

[Programare]Secventa N-patrata

Recommended Posts

Posted

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 patrat

1 1 2 6 ... termenii

Care e suma cifrelor celui de-al 10-lea termen din secventa anterioara?

Posted

#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

Posted

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:4
36:9
1764:18
3261636:27
2829760580:47
704033252:26
763197476:50
1227672452:38

haha wolframalpha ftw :D

165506647324519964198468195444439180017513152706377484976912705487864128102426408447950441478478159989636

faceti voi suma !

LE: hahahahah

http://www.wolframalpha.com/input/?i=sum+of+digits+165506647324519964198468195444439180017513152706377484976912705487864128102426408447950441478478159989636

rezultat : 495

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...