Advertisement
satriafu5710

Bilangan Habis dibagi 3 & 5 Java

Dec 5th, 2020
2,607
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  1. package com.tutorial;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner userInput = new Scanner(System.in);
  9.         int angka;
  10.         System.out.println("\t Habis Dibagi 3 & 5 \n");
  11.  
  12.         System.out.print("\n Masukkan Batas Nilai : ");
  13.         angka = userInput.nextInt();
  14.  
  15.         System.out.print("\n Bilangannya : ");
  16.         for (int i = 1; i <= angka; i++) {
  17.             if (i % 3 == 0 && i % 5 == 0) {
  18.                 System.out.print(i + " ");
  19.             }
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement