Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e92a2ec

Browse files
Merge pull request #1 from prathimacode-hub/master
Added jumping number program
2 parents ff38df9 + aa82adc commit e92a2ec

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

‎Basic/jumping no.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#Given a positive number N, check if the number is a Jumping number or not.
2+
#A number is defined as a Jumping Number if all adjacent digits in it have an absolute difference of 1.
3+
#For example 2, 23 and 4343456 are Jumping numbers but 296 and 89498 are not
4+
5+
num = input("Enter a number ")
6+
lst = [int(x) for x in num]
7+
n = len(lst)
8+
res = 1
9+
for ele in range(0,n-1):
10+
if abs(lst[ele] - lst[ele+1]) != 1:
11+
res = 0
12+
if res == 1:
13+
print("JUMPING NUMBER")
14+
else:
15+
print("NOT A JUMPING NUMBER")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /