• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

Calculating the sum of numbers in a user defined range.

 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I have the error of " not a statement " for the line in which I applied the formula for summation. The formula given is (n-m+1)(n+m) /2 , where m is the starting number and n is the last number.
 
Bartender
Posts: 1051
5
Hibernate Eclipse IDE Chrome
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For multiplication, you need to use the * character.

So, for a variable x, multiplying it by 2 would be 2 * x, not 2x.
 
WeiJie Lim
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

James Boswell wrote:For multiplication, you need to use the * character.

So, for a variable x, multiplying it by 2 would be 2 * x, not 2x.



Oh gosh, I totally missed the * after trying to debug my code for quite some time..

Thanks a million.
 
It's never done THAT before. Explain it to me tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic