This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Android and the fly likes problem in UVA Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "problem in UVA" Watch "problem in UVA" New topic

problem in UVA

diaa baraka

Joined: Dec 14, 2012
Posts: 12
i've recently started in UVA website and i can't find why it doesn't accept my code
this is the link of the problem :
and this is my code:
import java.util.Scanner;

public class Main {

public static void main(String[] args) {
Scanner input = new Scanner(;
while (input.hasNext()) {

long i = input.nextLong();
long j = input.nextLong();
int maxCount = 0;
int count;
long n;
for (long j2 = i; j2 <= j; j2++) {
count = 0;
n = j2;
while (n != 1) {
if (n % 2 != 0) {
n = 3 * n + 1;
} else {
n = n / 2;
if (count >= maxCount) {
maxCount = count;


System.out.println(i+" "+j+" "+maxCount);

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41148
What does this have to do with Android (which this forum is all about) ?

You should also post what the actual problem is. Folks here are unlikely to know what the UVA web site is or does, and what, exactly, you mean by "it doesn't accept my code".

Ping & DNS - my free Android networking tools app
It is sorta covered in the JavaRanch Style Guide.
subject: problem in UVA
Similar Threads
Finding primitive polynomials
Right triangles
Multi dimensional array
null pointer exception in Game Of Life
Can't Find the bug...