<p>Hi, I need help.</p>
<div style="margin: 0in 0in 0pt"><span style="color: black">I need to write a program that, for input integer n > 0, output the row vector [k<sub>1</sub>,k<sub>2</sub> . . . , k<sub>n</sub>].</span></div>
<div style="margin: 0in 0in 0pt"><span style="color: black">For example, when input n = 8, the output is [1, 4, 11, 31, 83, 227, 616, 1674].</span></div>
<div style="margin: 0in 0in 0pt"> </div>
<div style="margin: 0in 0in 0pt"> This is what I have:</div>
<pre>
harmonic1 := proc ( n )<br /> local s, h, k, j;
h := LinearAlgebra[Dimension](x);<br /> s := 0;
<br /> for k from 1 to h do <br /> while n > 0 do<br /><br /> s := s + 1/j[K]; <br /> end do;
end do;
<br /> return s;
end proc;</pre>
<pre>
</pre>
<p>But is not woking.</p>
<p>Can some one help me please</p>
<p>Thanks ^_^</p>
Hi, I need help. I need to
Hi, I need help.
I need to write a program that, for input integer n > 0, output the row vector [k1,k2 . . . , kn].
For example, when input n = 8, the output is [1, 4, 11, 31, 83, 227, 616, 1674].
This is what I have:
But is not woking.
Can some one help me please
Thanks ^_^
one approach
The real challenge is making this reasonably fast. Here is my first attempt, not particularly fast. This isn't the nicest approach, from a pedagogical viewpoint.
Harmonic := module() export ModuleApply; local nmax; nmax := 1; ModuleApply := proc(n::posint) option remember; local k; procname(nmax) + add(1/k,k=nmax+1..n); end proc; ModuleApply(1) := 1; end module: A := proc(n::posint) local k; for k while Harmonic(k) < n do end do; return k; end proc: harmonic1 := proc(n) Vector['row'](n, A); end proc: harmonic1(3); [1, 4, 11]What are you trying to do?
The first thing you have to do is tell us what you're trying to do. What are k1, k2, ..., kn supposed to be? I can't make any sense of [1, 4, 11, 31, 83, 227, 616, 1674], and neither can the Encyclopedia of Integer Sequences or Maple's guessgf.
A004080
I believe it is A004080 in www.research.att.com/~njas/sequences/Seis.html
A004080
Yes, I saw that after I saw your posting... My fault, I miscopied the search string. In any case, I think my advice was sound: whether trying to do a problem oneself or asking somebody else for help, it's important to state the problem clearly.