Difference between revisions of "CHECKSUM"

From Pickwiki
Jump to navigationJump to search
(Java implementation of the UniBasic CHECKSUM function)
 
m (link fix)
 
Line 1: Line 1:
Java implementation of the UniBasic CHECKSUM function:
+
Java implementation of the [[UniBasic]] CHECKSUM function:
  
 
<pre>
 
<pre>

Latest revision as of 23:48, 26 February 2015

Java implementation of the UniBasic CHECKSUM function:

static long checksum( String input )
{
      char[] chars = new char[ input.length() ];
      input.getChars(0, chars.length, chars, 0);
     
      long answer = 0L;
      for (int i = 0; i< chars.length ; i++) {
         answer += ((int)chars[i]) * (i+1);
      }
      
      return answer;
}