Last active
          November 12, 2017 12:32 
        
      - 
      
- 
        Save jtulach/dd7ab83a1acec7a7faac076dece3b837 to your computer and use it in GitHub Desktop. 
    Greatest Divisor of two numbers
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package dew.demo.namesmodel; | |
| import net.java.html.json.Model; | |
| import net.java.html.json.Property; | |
| import net.java.html.json.ComputedProperty; | |
| @Model(targetId="", className="GreatDiv", properties={ | |
| @Property(name = "a", type=int.class), | |
| @Property(name = "b", type=int.class) | |
| }) | |
| class GreatestDivisor { | |
| @ComputedProperty | |
| static int nsd(int a, int b) { | |
| if (a < b) { | |
| return nsd(b - a, a); | |
| } else if (a > b) { | |
| return nsd(a - b, b); | |
| } | |
| return a; | |
| } | |
| public static void main(String... args) { | |
| GreatDiv pageModel = new GreatDiv(9,15); | |
| pageModel.applyBindings(); | |
| } | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | a: <input data-bind="textInput:a"/> | |
| b: <input data-bind="textInput:b"/> | |
| Greatest divisitor of a and b: <span data-bind="text: nsd"></span> | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment