Multiply numbers after each other -
exercise product1ton (loop): write program called product1ton compute product of integers 1 10 (i.e., 1×2×3×...×10). try computing product 1 11, 1 12, 1 13 , 1 14. write down product obtained , explain results.
how can this, , multiple ways?
try this:
private int product1ton(int n){ int result = 1, ctr = 1; while(ctr <= n){ result *= ctr++; } return result; }
hope helps.
Comments
Post a Comment