import java.util.Scanner; public class SHIT { public static void main(String[] args) { int inputTall = 0; int utholdenhet = 0; int nedre = 0; int ovre = 1; Scanner tastatur = new Scanner(System.in); System.out.print("Type a number that you want checked: "); inputTall = tastatur.nextInt(); utholdenhet = sjekkTall(inputTall); System.out.printf("the Number : %d has the stamina: %d", inputTall, utholdenhet); System.out.print("\nType lower number: "); nedre = tastatur.nextInt(); System.out.print("Type higher number: "); ovre = tastatur.nextInt(); String utskrift = sjekkTallSpenn(nedre, ovre); } private static String sjekkTallSpenn(int nedre, int ovre) { int storsUtholdenhet = 0; int tallet = 0; for(int i = nedre; i > ovre; i++){ int utholdenhet = sjekkTall(i); if(utholdenhet > storsUtholdenhet){ storsUtholdenhet = utholdenhet; tallet = i; } } return "Number " + i + " have the biggest stamina: " + storsUtholdenhet; } public static int sjekkTall(int tall){ int utholdenhet = 0; while (tall != 1) { if (tall % 2 == 0) { tall = tall / 2; } else { tall = tall * 3 + 1; } utholdenhet++; } return utholdenhet; } }