ok i just started loops in my java class and im stuck on getting this loop working i dunno what all math to do to get these numbers for the output
97, 84, 72, 61, 51, ... 1
ThUgLoRd 0 Newbie Poster
Recommended Answers
Jump to Posttry this...
int diff=14
for(int lp=97;lp>0;lp-=diff)
{
System.out.println(lp);
diff--;
}try that, think it should work
Jump to PostThe first implementation doesnt work because diff ends up becoming negative before the value reaches 0. Should be an infinite loop if my quick glance is correct.
All 6 Replies
cms271828 2 Junior Poster
Goitse 2 Newbie Poster
TylerSBreton 13 Junior Poster in Training
cms271828 2 Junior Poster
bommavj 0 Newbie Poster
bommavj 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.