Java program on the Collatz Conjecture

Simple Java program on the Collatz Conjecture | Java programming | AskTheCode

public class CollatzConjecture{

public static void main(String[] args) {




static int f(int n){

if (n%2==0) {

return n/2;



return 3*n+1;




25 views0 comments

Recent Posts

See All

Calculate BMI in Java | AskTheCode

Write a Java program that reads values for weight in kilograms and height in centimeters and prints out the BMI... interpretation of it...

"Believe you can and you're halfway there"