Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Q3- For an integer N, your task is to calculate sum of first N natural numbers.
- Ans-static void sum(int N){
- //Enter your code here
- long sum=0;
- for( long i =0;i<=N;i++){
- sum = sum +i;
- }
- System.out.print(sum);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement