<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://wiki.inthewings.net/index.php?action=history&amp;feed=atom&amp;title=CIS_3020_Stupid</id>
	<title>CIS 3020 Stupid - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.inthewings.net/index.php?action=history&amp;feed=atom&amp;title=CIS_3020_Stupid"/>
	<link rel="alternate" type="text/html" href="http://wiki.inthewings.net/index.php?title=CIS_3020_Stupid&amp;action=history"/>
	<updated>2026-05-06T08:13:49Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.33.0</generator>
	<entry>
		<id>http://wiki.inthewings.net/index.php?title=CIS_3020_Stupid&amp;diff=2007&amp;oldid=prev</id>
		<title>Jka at 17:40, 3 April 2007</title>
		<link rel="alternate" type="text/html" href="http://wiki.inthewings.net/index.php?title=CIS_3020_Stupid&amp;diff=2007&amp;oldid=prev"/>
		<updated>2007-04-03T17:40:20Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;So, here is some really stupid code that I have come up with while I was taking this class.&lt;br /&gt;
==Implementation of multiplication using recursion==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  private static int mult(int a, int b) {&lt;br /&gt;
    int result;&lt;br /&gt;
    if (b&amp;lt;=1) {&lt;br /&gt;
      result = a;&lt;br /&gt;
    } else {&lt;br /&gt;
      result = a + mult(a,b-1);&lt;br /&gt;
    }&lt;br /&gt;
    return result;&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==Implementation of Convergence Lecture==&lt;br /&gt;
This was part of a lecture that showed us something about convergence. Apparently this particular convergence has never actually been proven by mathemeticians, but regardless this is an implementation of the convergence using recursion.&lt;br /&gt;
&lt;br /&gt;
The actual convergence works like this:&lt;br /&gt;
* Pick a positive integer&lt;br /&gt;
** If that integer is even, divide it by two&lt;br /&gt;
** If it is odd, multiply by three, then add one&lt;br /&gt;
* Lather, rinse, repeat&lt;br /&gt;
* Eventually this will converge on one, though it has never been proven mathematically&lt;br /&gt;
&lt;br /&gt;
Here is the code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import java.util.Scanner;&lt;br /&gt;
&lt;br /&gt;
public class Converge {&lt;br /&gt;
  public static void main (String[] args) {&lt;br /&gt;
    System.out.println(&amp;quot;Enter a positive integer:&amp;quot;);&lt;br /&gt;
    Scanner sc = new Scanner(System.in);&lt;br /&gt;
    int num = sc.nextInt();&lt;br /&gt;
    converge(num);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  private static int converge(int input) {&lt;br /&gt;
    System.out.printf(&amp;quot;Input: %d\n&amp;quot;, input);&lt;br /&gt;
    int output;&lt;br /&gt;
    if (input&amp;lt;=1) {&lt;br /&gt;
      output = input;&lt;br /&gt;
    } else {&lt;br /&gt;
      if (even(input)) {&lt;br /&gt;
        output = converge(input/2);&lt;br /&gt;
      } else {&lt;br /&gt;
        output = converge((mult(input, 3)) + 1);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    return output;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  private static boolean even(int x) {&lt;br /&gt;
    return (x % 2 == 0);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  private static int mult(int a, int b) {&lt;br /&gt;
    int result;&lt;br /&gt;
    if (b&amp;lt;=1) {&lt;br /&gt;
      result = a;&lt;br /&gt;
    } else {&lt;br /&gt;
      result = a + mult(a,b-1);&lt;br /&gt;
    }&lt;br /&gt;
    return result;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jka</name></author>
		
	</entry>
</feed>