Skip to content
Open

E #1

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d446906
3n +1
Feb 6, 2018
47ce516
Update 3n + 1 Problem
jaredpohlmann Feb 6, 2018
57ea368
Update 3n + 1 Problem
jaredpohlmann Feb 6, 2018
3b499c7
Update 3n + 1 Problem
jaredpohlmann Feb 6, 2018
c849e17
Delete 2n+1 problem.java
piiamt Feb 6, 2018
c1b2954
Delete 2n+1 problem.java
piiamt Feb 6, 2018
ad48051
Update 3n + 1 Problem
jaredpohlmann Feb 6, 2018
c8f1686
Merge pull request #3 from jaredpohlmann/master
jaredpohlmann Feb 6, 2018
378094c
here is my Lab 2 guessing game
Alexkerr7 Feb 6, 2018
2deb824
appikene
piiamt Feb 6, 2018
d892cb9
Merge pull request #5 from piiamt/master
piiamt Feb 6, 2018
c086d09
homework
addyvinton Feb 6, 2018
45f0e23
lab 2
SkylarGalloway Feb 6, 2018
15da6ae
Merge pull request #7 from SkylarGalloway/master
SkylarGalloway Feb 6, 2018
177e880
Updated Lab 2
SkylarGalloway Feb 6, 2018
3266684
Merge pull request #8 from SkylarGalloway/master
SkylarGalloway Feb 6, 2018
3b1a751
Create Jackson_Maschman_Question_2
NoeBuddy Feb 7, 2018
86183ba
Merge pull request #9 from elijahbeed/master
elijahbeed Feb 8, 2018
061eda9
hi
kbenes2 Feb 8, 2018
3830961
Lab 2
jackhinze Feb 8, 2018
eac8614
Merge branch 'master' of https://github.com/CMPSC1500-Spring17/Lab-2
jackhinze Feb 8, 2018
d3401b1
Create bkeller lab2
bkeller17 Feb 8, 2018
9b29aad
Create Ben Wortman
bwortman2 Feb 8, 2018
2b86763
Add files via upload
bwortman2 Feb 8, 2018
0b7299f
Delete Ben Wortman
bwortman2 Feb 8, 2018
5a8de1f
Updated Lab 2
SkylarGalloway Feb 8, 2018
694fba2
Merge pull request #11 from SkylarGalloway/master
SkylarGalloway Feb 8, 2018
71932fc
test
ylopez20 Feb 8, 2018
05e66b9
Lab2
ylopez20 Feb 8, 2018
ffe39cd
Merge branch 'master' of
ylopez20 Feb 8, 2018
2683d5f
lab2
ylopez20 Feb 8, 2018
912faaa
Merge pull request #4 from Alexkerr7/master
jifland Apr 10, 2018
0ba2f73
Merge pull request #10 from bkeller17/master
jifland Apr 10, 2018
485ecb2
Merge pull request #6 from addyvinton/master
jifland Apr 10, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions 2n+1 problem.java

This file was deleted.

31 changes: 31 additions & 0 deletions Alex Kerr labs/Alex Kerr Lab 2 guessing game.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import java.Math

int num = math.Random(100) + 1;
Print "guess a number between 100 and 1, what is your guess?";
import user.guess;
int n = 0;
while (num != guess)
{
if(num > guess)
{
print " your guess is too low, guess again ";
import new user.guess;
n++
}
else if(num < guess)
{
print " your guess is too high, guess again ";
import new user.guess;
n++
}
else if(num == guess)
{
Break;
}

}
if(num == guess)
{
n++
Print "you guessed right! it took you " + n + " tries to guess the number correctly";
}
26 changes: 26 additions & 0 deletions Ben Wortman/BW Lab-2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@




public class Problem2{

int num = 1579; //starting number
System.out.println("The number is " + num); //says the starting number

for(i=0; number>1; i++) //add one per loop

{if (num % 2==0) //if the number is divisible by 2 is a whole number
{ num = num/2; //then divide the number by 2
System.out.println("The current number is " +num);} //prints number after divided by 2

else {num = num*3+1; //if not divisible by 2 multiply by 3 and add 1

System.out.println("The current number is " +num)}} //prints the number after multiplied by 3 and one added

System.out.println("There were" +i " operations")} //prints how many times was a number sent through before it was 1






24 changes: 24 additions & 0 deletions Jack Hinze/Lab 2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
3n+1 Problem
Your program will be given a positive number (less than 10,000). Your program will take the number and follow the appropriate step below:

when n is even, divide n by 2
when n is odd, multiply n by 3, and then add 1
When n is equal to one you stop, otherwise you pick the appropriate step again.

Please print out the sequence of numbers that lead to 1, starting with n, and how many times (in sumation) the above two commands are run.

Integer n = input number;
step=0
While (n > 1){
if (n%2==0){
n = n/2;
system.out.print(n);
step +=1
}
else{
n = 3*n + 1;
system.out.print(n);
step +=1;
}
}
system.out.print("# of steps:" step)
25 changes: 25 additions & 0 deletions Jackson_Maschman_Question_2
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
public class Lab2 {
public static void main(String[] args)
{
//This is problem #2.
for(int n = 1; n < 10000; n++) //The parameters you set were numbers from 0 to less than 10000, so... here you go.
{
int counter = 0; //This sets the counter to 0 each time it finishes with one of the numbers.
while(n != 1) //This checks the number each loop to see if it has reached 1 yet.
{
if (n % 2 == 0) //This organizes the even numbers into this category.
{
n = (n / 2);
counter = counter + 1;
}

else { /* This organizes the odd numbers into this category. */
n = ((n * 3) + 1);
counter = counter + 1;
}

}
System.out.println(n + " It took " + counter + " loops to complete.");
}
}
}
15 changes: 15 additions & 0 deletions Jared Pohlmann/3n + 1 Problem
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Integer num = input number;
step=0
While (num > 1){
if (num%2==0){
num= num/2;
system.out.print(num);
step += 1;
}
else{
num = num*3 +1;
system.out.print(num);
step += 1;
}
}
system.out.print("# of steps:" step)
23 changes: 23 additions & 0 deletions Kristen Benes/Lab 2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Lab 2
Problem 2
Your program will be given a positive number (less than 10,000). Your program will take the number and follow the appropriate step below:
When n is even, divide n by 2
when n is odd, multiply n by 3, and then add 1
When n is equal to one you stop, otherwise you pick the appropriate step again.
Please print out the sequence of number that lead to 1, starting with n, and how many times (in sumation) the above two commands are run.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
n = input number;
step = 0
While (n > 1){
If (n%2==0){
n = (n/2);
system.out.print(n);
step +=1;
}
Else{
n = n*3+1;
system.out.print(n);
step +=1;
}
}
system.out.print("# of steps:" step)
16 changes: 16 additions & 0 deletions addyvinton/addyvintonlab2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
n = number

for (
if(n%2 == 0)
{

n = n/2

}

else
{

n = (n*3) + 1

}
23 changes: 23 additions & 0 deletions bkeller lab2
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
PROBLEM 3



n = getRandomNumber(0:100);
u = user input;
"guess" = 1
If (n > u){
system.out.print(n);
"LOW";
"guess"+=1;
}
If (n < u){
system.out.print(n);
"HIGH";
"guess"+=1;
}
If (n == u)
system.out.print(n);
"CORRECT";
}
}
system.out.print("number of "guesses:" guesses)
14 changes: 14 additions & 0 deletions piiamt/2n+1 problem.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
public class Problem2{
int number = 56; //this is the number given to the program
System.out.println("The inserted number is " + number); //prints the number given to the program
for (i=0; number>1; i++){ //every loop the counter i will be increased by one, that is the total number of operations. continues as long as number is bigger than 1
if (number%2 != 0){ //if number/2 does not have a remainder (number is divisible by 2) then
number=number/2; //the number will be redefined as the number itself divided by 2
System.out.println("The current number is "+number); //prints the number after dividing it by 2
}
else { //when the condition of the if statement does not apply (number is not even) then executes this part that
number=number*3+1; //multiplies the number by 3 and adds 1, redefines number to it.
System.out.println("The current number is "+number);
}
System.out.println("The total number of operations was "+i) //prints out the number of operations
}
35 changes: 35 additions & 0 deletions skylar galloway lab/Lab2 3n+1 problem.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
3n+1

The 3n + 1 problem
Your program will be given a positive number (less than 10,000). Your program will take the number and follow the appropriate step below:

when n is even, divide n by 2
when n is odd, multiply n by 3, and then add 1
When n is equal to one you stop, otherwise you pick the appropriate step again.

Please print out the sequence of numbers that lead to 1, starting with n, and how many times (in sumation) the above two commands are run.

n = input number
int counter=0 /*the value that keeps track of how many times number runs through the loop*/

for(int i=0, n!=1 /*(this is tested before loop is executed)*/, i++){
if (n%2==0){
w=n/2 //can be n=n/2
Print w
count= counter +1
counter=count
n=w
}
else { // (n%2!=0)
x=3*n
y=x+1
coUnt= counter +1
counter=coUnt
Print y
n=y
}
}
Print n
Print "The number of times ran throught"+counter


17 changes: 17 additions & 0 deletions ylopez20/Lab2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//Problem 2
~~~
n = input number
for(n=1, n<1000)
{
n counter = 0;
while(n!=1)
{
if(n%2==0)
ncounter= n+1;
}

else
n=n*3+1;
ncounter =n+1
}
~~~