Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions java/IsDivisibleby2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import java.util.*;
class Main {
public static void main(String arg[]) {
Scanner in = new Scanner(System.in);
System.out.println("Enter Number");
String n = in.nextLine();
int l = n.length();
if (n.charAt(l - 1) == '2' || n.charAt(l - 1) == '4' || n.charAt(l - 1) == '6' || n.charAt(l - 1) == '8' || n.charAt(l - 1) == '0')
System.out.println("Number is divisible by 2");
else
System.out.println("Not Divisible by 2");
}
}

15 changes: 15 additions & 0 deletions python/divisibility_by_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
print("Please Enter a number:")
n = int(input())

s = bin(n)

if s[-1]=="1":
print("The Number is not divisible by 2")
else:
print("The Number is divisible by 2")