Revision ce72bcaa-a43f-45a7-9104-922fd82cde93 - Code Golf Stack Exchange

# TI-BASIC (TI-84), <s>30</s> 23 bytes

 :2Ans=sum(seq(Ans/Xnot(remainder(Ans,X)),X,1,Ans,1

<s>Horribly inefficient, but it works.</s> 
Reducing the bytecount sped up the program by a lot. 
Input is in `Ans`. 
Output is in `Ans` and is automatically printed out when the program completes.

**Explanation:** 
(TI-BASIC doesn't have comments, so just assume that `;` makes a comment)

 :2Ans=sum(seq(Ans/Xnot(remainder(Ans,X)),X,1,Ans ;Full program
 
 2Ans ;double the input
 seq( ;generate a list
 X, ;using the variable X,
 1, ;starting at 1,
 Ans ;and ending at the input
 ;with an implied increment of 1
 Ans/X ;from the input divided by X
 not( ), ;multiplied by the negated result of
 remainder(Ans,X) ;the input modulo X
 ;(result: 0 or 1)
 sum( ;sum up the elements in the list
 = ;equal?

**Example:**

 6
 6
 prgmCDGF2
 1
 7
 7
 prgmCDGF2
 0

---
**Note:** The byte count of a program is evaluated using the value in **[MEM]**>**[2]**>**[7]** (36 bytes) then subtracting the length of the program's name, `CDGF2`, (5 bytes) and an extra 8 bytes used for storing the program:

36 - 5 - 8 = 23 bytes

AltStyle によって変換されたページ (->オリジナル) /