Advertisement
CR7CR7

ref

Sep 21st, 2022
741
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.34 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class DevisibleByThree{
  3. public static void main (String[] args){
  4.   Scanner sc =new Scanner(System.in);
  5.   int num =Integer.parseInt(sc.nextLine());
  6.   int sum=0;
  7. for(int i =0;i<=num*2;i++){
  8.  
  9.   if(i % 2 !=0){
  10.     sum =sum +i;
  11.     System.out.println(i);
  12.   }
  13.  
  14.   }
  15.   System.out.println("Sum: " +sum);
  16.  }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement