Created
April 5, 2019 17:50
-
-
Save parvinderandroid/8a68182103eb2f0bbc23ae061bc98446 to your computer and use it in GitHub Desktop.
The Code
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
#include <stdio.h> | |
int isDivisible(int num) { | |
for(int i = 20; i >= 1; i--) | |
if(num % i != 0) | |
return 0; | |
return 1; | |
} | |
int main() { | |
int i = 1; | |
while(1) { | |
if(isDivisible(i)) { | |
printf("%d\n", i); | |
break; | |
} | |
i++; | |
} | |
return 0; | |
} |
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
class Euler { | |
public static boolean isDivisible(int num) { | |
for(int i = 20; i >= 1; i--) | |
if(num % i != 0) | |
return false; | |
return true; | |
} | |
public static void main(String[]args) { | |
int i = 1; | |
while(true) { | |
if(isDivisible(i)) { | |
System.out.println(i); | |
break; | |
} | |
i++; | |
} | |
} | |
} |
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
def isDivisible(num): | |
for i in range(20, 1, -1): | |
if num % i != 0: | |
return False | |
return True | |
i = 1 | |
while(True): | |
if(isDivisible(i)): | |
print(i) | |
break | |
i += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment