Skip to content

Instantly share code, notes, and snippets.

@parvinderandroid
Created April 5, 2019 17:50
Show Gist options
  • Save parvinderandroid/8a68182103eb2f0bbc23ae061bc98446 to your computer and use it in GitHub Desktop.
Save parvinderandroid/8a68182103eb2f0bbc23ae061bc98446 to your computer and use it in GitHub Desktop.
The Code
#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;
}
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++;
}
}
}
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