Advertisement
RazorBlade57

GCD

Nov 28th, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.45 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class LoopStats {
  3.  
  4.     public static void main(String[] args) {
  5.        
  6.         Scanner keyboard = new Scanner(System.in);
  7.         System.out.println("Please enter two mumber to find the Greatest Common Denominator up to 30 - ");
  8.         int word = keyboard.nextInt();
  9.         int numb = keyboard.nextInt();
  10.        
  11.         if(word > 30 || numb > 30){
  12.             System.exit(1);
  13.         }
  14.        
  15.  
  16.        
  17.        
  18.        
  19.         for (int i = 0; i >= 30; i++ ){
  20.             if (numb %1 == 0 && word %1 == 0 ){
  21.                 System.out.println("You GCD is :: 1");
  22.             }else if(numb %2 == 0 && word %2 == 0 ){
  23.                 System.out.println("You GCD is :: 2");
  24.             }else if(numb %3 == 0 && word %3 == 0 ){
  25.                 System.out.println("You GCD is :: 3");
  26.             }else if(numb %4 == 0 && word %4 == 0 ){
  27.                 System.out.println("You GCD is :: 4");
  28.             }else if(numb %5 == 0 && word %5 == 0 ){
  29.                 System.out.println("You GCD is :: 5");
  30.             }else if(numb %6 == 0 && word %6 == 0 ){
  31.                 System.out.println("You GCD is :: 6");
  32.             }else if(numb %7 == 0 && word %7 == 0 ){
  33.                 System.out.println("You GCD is :: 7");
  34.             }else if(numb %8 == 0 && word %8 == 0 ){
  35.                 System.out.println("You GCD is :: 8");
  36.             }else if(numb %9 == 0 && word %9 == 0 ){
  37.                 System.out.println("You GCD is :: 9");
  38.             }else if(numb %10 == 0 && word %10 == 0 ){
  39.                 System.out.println("You GCD is :: 10");
  40.             }else if(numb %11 == 0 && word %11 == 0 ){
  41.                 System.out.println("You GCD is :: 11");
  42.             }else if(numb %12 == 0 && word %12 == 0 ){
  43.                 System.out.println("You GCD is :: 12");
  44.             }else if(numb %13 == 0 && word %13 == 0 ){
  45.                 System.out.println("You GCD is :: 13");
  46.             }else if(numb %14 == 0 && word %14 == 0 ){
  47.                 System.out.println("You GCD is :: 14");
  48.             }else if(numb %15 == 0 && word %15 == 0 ){
  49.                 System.out.println("You GCD is :: 15");
  50.             }else if(numb %16 == 0 && word %16 == 0 ){
  51.                 System.out.println("You GCD is :: 16");
  52.             }else if(numb %17 == 0 && word %17 == 0 ){
  53.                 System.out.println("You GCD is :: 17");
  54.             }else if(numb %18 == 0 && word %18 == 0 ){
  55.                 System.out.println("You GCD is :: 18");
  56.             }else if(numb %19 == 0 && word %19 == 0 ){
  57.                 System.out.println("You GCD is :: 19");
  58.             }else if(numb %20 == 0 && word %20 == 0 ){
  59.                 System.out.println("You GCD is :: 20");
  60.             }else if(numb %30 == 0 && word %30 == 0 ){
  61.                 System.out.println("You GCD is :: 30");
  62.         }
  63.        
  64.        
  65.        
  66.        
  67.        
  68.         }
  69.    
  70.    
  71.    
  72.    
  73. /*
  74.   1) 1, 4, 7, 10, 13
  75.  
  76.   2) 11
  77.  
  78.   3) 20
  79.  
  80.   4) 30
  81.  
  82.   5) 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
  83.  
  84. */
  85.  
  86.  
  87.    
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement