Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2003
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: question..

  • To: mathgroup at smc.vnet.net
  • Subject: [mg43857] Re: question..
  • From: "Peltio" <peltio at twilight.zone>
  • Date: Thu, 9 Oct 2003 01:54:30 -0400 (EDT)
  • References: <bm0jfj$pps$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

"Ghassan Shahin" wrote

>i want to use mathematica for sums..but i need to sum from 1 to 100
>except same integer numbers, say 2,6,8..what is the code for such a
>task?

If I got it right and by 'some' you mean 'only a few', I think that the
fastest way to do what you want is to actually sum up to 100 and then
subtract the (few) values you didn't want to include in the sum

    f[k]:=k;
    Sum[f[k],{k,1,100}]-f/@{2,6,8}

In a procedure:

    SumEx[f_, {k_, oth__}, exclist_List] :=
        Sum[f, {k, oth}] - Plus @@ (f /. k -> # & /@ exclist)

Example:

    f[k]:=k;
    SumEx[f[k], {k, 1, 100}, {2, 6, 8}]

cheers,
Peltio
invalid addrees in reply-to. Demunging required to mail me.




  • Prev by Date: Re: Fields or forms on manifolds
  • Next by Date: Re: Using Symbols in Functions
  • Previous by thread: Re: question..
  • Next by thread: Re: question..