Skip to content

guevaracodina/collatz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

collatz

This function checks for the Collatz conjecture for a given number. It can be customized to check other variants different to 3n+1. Takes a number n. If it’s even, divide by 2. If it’s odd, multiply by 3 and add 1. Repeat. Do all starting numbers lead to 1?

INPUTS

n A positive real number greater than 2.

[OPTIONAL INPUTS]

modNum Modulus number, default modNum = 2
multFac Multiplication factor, default multFac = 3
addSum Sumand to add, default addSum = 1
nStop stop after nStop steps (avoid infinite loop)
default nStop = 1000

OUTPUT

n Final value (n=1)
______________________________________________________________________________
Copyright (C) 2019 Edgar Guevara, PhD
______________________________________________________________________________
View collatz on File Exchange

About

checks for the Collatz conjecture for a given number

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages