Group Abstract Group Abstract

Message Boards Message Boards

0
|
6.2K Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

HELP with Mathematica Homework

Posted 11 years ago
POSTED BY: Erly Solis
2 Replies

Wolfram Community is only for the discussions of Wolfram Technologies.

Other unrelated topics (for example, obvious homework requests, or purely scientific topics) should be posted on different, appropriate forums.

We are very grateful to all contributors offering help and contributing to Community.

But unfortunately we cannot support discussions outside Community guidelines:

http://community.wolfram.com/guidelines

If you see inappropriate discussions please do not respond in future but let moderators know by flagging the post or emailing at:

wolfram-community@wolfram.com

Thank you for your patience and understanding!

Sincerely, Moderation Team

POSTED BY: EDITORIAL BOARD

Hi,

sounds like homework. This should work:

f[m_Integer] := Module[{k = m}, Table[Print[2 (j - 1) + 1], {j, 1, k}]; 
  StringJoin[{{"The sum is ", ToString[Evaluate[Total[Table[2 (j - 1) + 1, {j, 1, k}]]]]}, "."}]]

You can easily evaluate that for three different numbers.

The print command is somewhat artificial, because table does it anyway. But here is a variant where the Print is important:

g[m_Integer] := Module[{k = m}, For[j = 1, j <= k, j++, Print[2 (j - 1) + 1]]; 
  StringJoin[{{"The sum is ", ToString[Evaluate[Total[Table[2 (j - 1) + 1, {j, 1, k}]]]]}, "."}]]

Cheers,

M.

POSTED BY: Marco Thiel