GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add 728_Self_Dividing_Numbers.java (#24) · ChenGavi/leetcode@1ca0f6e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • java
    • 728_Self_Dividing_Numbers.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎java/728_Self_Dividing_Numbers.java‎

Copy file name to clipboard
+35Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
class Solution {
2+
public List<Integer> selfDividingNumbers(int left, int right)
3+
{
4+
LinkedList list = new LinkedList();
5+
for(int i = left; i <= right; i++)
6+
{
7+
if(isSelfDiving(i))
8+
list.add(i);
9+
}
10+
return list;
11+
}
12+
13+
public boolean isSelfDiving(int num)
14+
{
15+
int digit = num % 10;
16+
int temp = num;
17+
boolean isTrue = true;
18+
while(temp != 0)
19+
{
20+
if(digit == 0 || num % digit != 0)
21+
{
22+
isTrue = false;
23+
break;
24+
}
25+
else
26+
{
27+
temp /= 10;
28+
digit = temp%10;
29+
}
30+
}
31+
return isTrue;
32+
33+
}
34+
35+
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.