1. PF Contest - Win "Conquering the Physics GRE" book! Click Here to Enter
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Help - Lisp program to calculate the sum of first N positive integers

  1. Oct 21, 2007 #1
    1. The problem statement, all variables and given/known data

    Write a Lisp program to calculate the sum of the first N positive integers where, for example, when N = 6 the sum of the first N = 21.

    2. Relevant equations

    If you try this out in tlisp at http://www.ugcs.caltech.edu/~rona/tlisp/ please note that the syntax for N - 1 is (+ N -1).

    Or if you try it out in the console of Allegro Common Lisp from http://www.franz.com the syntax is (- N 1).

    If you define your function as, for example, nsum, then the syntax for calling it with N = 6 is (nsum 6)

    3. The attempt at a solution

    Ok, I am no programmer so I don't even know where to start. This is not a programming class so I am not sure where to start.

    Any help or direction would be appreciated!
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted