Difference between revisions of "CHECKSUM"

From Pickwiki
Jump to navigationJump to search
(Java implementation of the UniBasic CHECKSUM function)
(No difference)

Revision as of 01:01, 9 November 2002

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;
}