No one has voted on any posts yet. Votes from other community members are used to determine a member's reputation amongst their peers.
5 Posted Topics
[code] int maxRun(){ int longestRun=-1; int maxRoll=0; int numOfRolls[]=new int[6]; int roll; //import java.util.Random @ header int counter=0; while(counter<20){ Random gen=new Random(); roll=gen.nextInt(6)+1; numOfRolls[roll-1]++; counter++; } for(int i=0;i<6;i++){ if(numOfRolls[i]>maxRoll){ longestRun=i+1; maxRoll=numOfRolls[i]; } } return longestRun; } } [/code]
I need to write a function that takes in an array of integers and an integer, checks if the sum of any of the numbers in the array is equal to the supplied integer. Any ideas would be much appreciated.
Here is one in python hope it helps: [code=python] def sumOfNumbers(lst,num): temp=0 while temp<len(lst): for i in range(0,len(lst)): if i==temp: continue if lst[temp]+lst[i]==num: return True temp=temp+1 return False print sumOfNumbers([1,2,3,4,5,6],3) [/code]
Here is a starter program that prints prime factors of a supplied numbers as a string.It's quite buggy as the input 8 yields 1.2.4 when what i wanted is 1.2.2.2 and I don't understand why the return in line 32 (commented) is not executed. [code=java] //program to compute prime factors …
Simple program to check whether a number is prime or not. Something is seriously wrong because every result I get is 'false'. Help me out please. Thanks in advance. [CODE] class primeTesting { public static void main(String[] args){ int i=7; //changing the value everytime always gives false.... ??? boolean bool=false; …
The End.
guyfrompluto