Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.46 KB | None | 0 0
  1. Punkt A:
  2.  
  3. public class Test {
  4.  
  5.     public static void main(String[] args) {
  6.        
  7.         int n = 40;
  8.        
  9.         for(int i=n; i>0; i--)
  10.         {
  11.             if(n%i==0)
  12.             {
  13.                 System.out.println(i);
  14.             }
  15.         }
  16.  
  17.     }
  18.  
  19. }
  20.  
  21.  
  22. Punkt B:
  23.  
  24. public class Test {
  25.  
  26.     public static void main(String[] args) {
  27.        
  28.         int n = 40;
  29.         int a=n;       
  30.        
  31.         while(n>0)
  32.         {
  33.             if(n%a==0)
  34.             {
  35.                 System.out.println(a);
  36.             }
  37.            
  38.             a--;
  39.            
  40.             if(a==0)
  41.             {
  42.                 break;
  43.             }
  44.         }
  45.  
  46.     }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement